
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 07/03/2011 00:41:36
-- Generated from EDMX file: D:\dev\MedLinkV1\MedLink2011.Web\Models\MedLinkModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [MedLink2011];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_AppointmentDoctor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Appointments] DROP CONSTRAINT [FK_AppointmentDoctor];
GO
IF OBJECT_ID(N'[dbo].[FK_Appointmentmed_Patient]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Appointments] DROP CONSTRAINT [FK_Appointmentmed_Patient];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Examsmed_BodyRegion]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BodyRegions] DROP CONSTRAINT [FK_med_Examsmed_BodyRegion];
GO
IF OBJECT_ID(N'[dbo].[FK_InvoiceCharge]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Charges] DROP CONSTRAINT [FK_InvoiceCharge];
GO
IF OBJECT_ID(N'[dbo].[FK_ClinicChartPatients]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ClinicCharts] DROP CONSTRAINT [FK_ClinicChartPatients];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_CardioClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Cardios] DROP CONSTRAINT [FK_Evaluation_CardioClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_ConstitutionalClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Constitutionals] DROP CONSTRAINT [FK_Evaluation_ConstitutionalClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_EntClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Ents] DROP CONSTRAINT [FK_Evaluation_EntClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_ExtremClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Extrems] DROP CONSTRAINT [FK_Evaluation_ExtremClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_GastroClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Gastros] DROP CONSTRAINT [FK_Evaluation_GastroClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_LymphClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Lymphs] DROP CONSTRAINT [FK_Evaluation_LymphClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_MuscClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Muscs] DROP CONSTRAINT [FK_Evaluation_MuscClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_NeckClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Necks] DROP CONSTRAINT [FK_Evaluation_NeckClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_NeuroClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Neuros] DROP CONSTRAINT [FK_Evaluation_NeuroClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_RespClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Respis] DROP CONSTRAINT [FK_Evaluation_RespClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Evaluation_SkinClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Evaluation_Skins] DROP CONSTRAINT [FK_Evaluation_SkinClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_Hereditary_IllnessesClinicChart]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hereditary_Illnes] DROP CONSTRAINT [FK_Hereditary_IllnessesClinicChart];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Consultationsmed_Consult_fees]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consult_Payments] DROP CONSTRAINT [FK_med_Consultationsmed_Consult_fees];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Consult_fees]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consult_Payments] DROP CONSTRAINT [FK_med_Patientmed_Consult_fees];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Consultationsmed_Diagnosis]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Diagnos] DROP CONSTRAINT [FK_med_Consultationsmed_Diagnosis];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Consultationsmed_Exams]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Exams] DROP CONSTRAINT [FK_med_Consultationsmed_Exams];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Consultationsmed_Insurance]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Insurances] DROP CONSTRAINT [FK_med_Consultationsmed_Insurance];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Consultationsmed_pathology]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Pathologies] DROP CONSTRAINT [FK_med_Consultationsmed_pathology];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Consultationsmed_Prescriptions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Prescriptions] DROP CONSTRAINT [FK_med_Consultationsmed_Prescriptions];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Doctormed_Consultations]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consultations] DROP CONSTRAINT [FK_med_Doctormed_Consultations];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Consultations]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consultations] DROP CONSTRAINT [FK_med_Patientmed_Consultations];
GO
IF OBJECT_ID(N'[dbo].[FK_LabDiagnosis]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Labs] DROP CONSTRAINT [FK_LabDiagnosis];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Diagnosismed_Exams]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Exams] DROP CONSTRAINT [FK_med_Diagnosismed_Exams];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Diagnosismed_Prescriptions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Prescriptions] DROP CONSTRAINT [FK_med_Diagnosismed_Prescriptions];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Doctormed_Diagnosis]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Diagnos] DROP CONSTRAINT [FK_med_Doctormed_Diagnosis];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Diagnosis]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Diagnos] DROP CONSTRAINT [FK_med_Patientmed_Diagnosis];
GO
IF OBJECT_ID(N'[dbo].[FK_DoctorPediatricPSC]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PediatricPSCs] DROP CONSTRAINT [FK_DoctorPediatricPSC];
GO
IF OBJECT_ID(N'[dbo].[FK_LabDoctor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Labs] DROP CONSTRAINT [FK_LabDoctor];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Doctormed_Exams]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Exams] DROP CONSTRAINT [FK_med_Doctormed_Exams];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Doctormed_Patient]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Patients] DROP CONSTRAINT [FK_med_Doctormed_Patient];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Doctormed_Surgeries]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Surgeries] DROP CONSTRAINT [FK_med_Doctormed_Surgeries];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Prescriptionsmed_Doctor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Prescriptions] DROP CONSTRAINT [FK_med_Prescriptionsmed_Doctor];
GO
IF OBJECT_ID(N'[dbo].[FK_med_ExamTypemed_ExamCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ExamCategories] DROP CONSTRAINT [FK_med_ExamTypemed_ExamCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_LabExams]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Labs] DROP CONSTRAINT [FK_LabExams];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Examsmed_ExamType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ExamTypes] DROP CONSTRAINT [FK_med_Examsmed_ExamType];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Exams]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Exams] DROP CONSTRAINT [FK_med_Patientmed_Exams];
GO
IF OBJECT_ID(N'[dbo].[FK_Hospital_bedInpatient_registrations]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Inpatient_regs] DROP CONSTRAINT [FK_Hospital_bedInpatient_registrations];
GO
IF OBJECT_ID(N'[dbo].[FK_Hospital_wardHospital_bed]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hospital_bed] DROP CONSTRAINT [FK_Hospital_wardHospital_bed];
GO
IF OBJECT_ID(N'[dbo].[FK_Hospital_buildingHospital_ward]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hospital_wards] DROP CONSTRAINT [FK_Hospital_buildingHospital_ward];
GO
IF OBJECT_ID(N'[dbo].[FK_Hospital_unitHospital_ward]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Hospital_wards] DROP CONSTRAINT [FK_Hospital_unitHospital_ward];
GO
IF OBJECT_ID(N'[dbo].[FK_Inpatient_registrationsPatients]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Inpatient_regs] DROP CONSTRAINT [FK_Inpatient_registrationsPatients];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Insurancemed_Insurance_Fees]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Insurance_Payments] DROP CONSTRAINT [FK_med_Insurancemed_Insurance_Fees];
GO
IF OBJECT_ID(N'[dbo].[FK_InsuranceInvoice]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Invoices] DROP CONSTRAINT [FK_InsuranceInvoice];
GO
IF OBJECT_ID(N'[dbo].[FK_InvoicePatients]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Invoices] DROP CONSTRAINT [FK_InvoicePatients];
GO
IF OBJECT_ID(N'[dbo].[FK_InvoicePayment]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Payments] DROP CONSTRAINT [FK_InvoicePayment];
GO
IF OBJECT_ID(N'[dbo].[FK_LabPatient]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Labs] DROP CONSTRAINT [FK_LabPatient];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Medical_History]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Medical_Histos] DROP CONSTRAINT [FK_med_Patientmed_Medical_History];
GO
IF OBJECT_ID(N'[dbo].[FK_MedicamentPrescriptions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Medicaments] DROP CONSTRAINT [FK_MedicamentPrescriptions];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_MedicationReaction]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MedicationReactions] DROP CONSTRAINT [FK_med_Patientmed_MedicationReaction];
GO
IF OBJECT_ID(N'[dbo].[FK_med_perinatalmed_newborn]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Newborns] DROP CONSTRAINT [FK_med_perinatalmed_newborn];
GO
IF OBJECT_ID(N'[dbo].[FK_med_pathology_categorymed_pathology]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Pathologies] DROP CONSTRAINT [FK_med_pathology_categorymed_pathology];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_PatientAllergy]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PatientAllergies] DROP CONSTRAINT [FK_med_Patientmed_PatientAllergy];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_perinatal]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perinatals] DROP CONSTRAINT [FK_med_Patientmed_perinatal];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Prescriptions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Prescriptions] DROP CONSTRAINT [FK_med_Patientmed_Prescriptions];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Surgeries]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Surgeries] DROP CONSTRAINT [FK_med_Patientmed_Surgeries];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_SystemReview]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[SystemReviews] DROP CONSTRAINT [FK_med_Patientmed_SystemReview];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_Vacines]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Vaccinations] DROP CONSTRAINT [FK_med_Patientmed_Vacines];
GO
IF OBJECT_ID(N'[dbo].[FK_med_Patientmed_WorkFlow]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[WorkFlows] DROP CONSTRAINT [FK_med_Patientmed_WorkFlow];
GO
IF OBJECT_ID(N'[dbo].[FK_PediatricPSCPatient]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PediatricPSCs] DROP CONSTRAINT [FK_PediatricPSCPatient];
GO
IF OBJECT_ID(N'[dbo].[FK_med_perinatalmed_perinatal_monitor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perinatal_monitors] DROP CONSTRAINT [FK_med_perinatalmed_perinatal_monitor];
GO
IF OBJECT_ID(N'[dbo].[FK_med_perinatalmed_puerperium_monitor]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Puerperium_monitors] DROP CONSTRAINT [FK_med_perinatalmed_puerperium_monitor];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Appointments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Appointments];
GO
IF OBJECT_ID(N'[dbo].[BodyRegions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BodyRegions];
GO
IF OBJECT_ID(N'[dbo].[Charges]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Charges];
GO
IF OBJECT_ID(N'[dbo].[ClinicCharts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ClinicCharts];
GO
IF OBJECT_ID(N'[dbo].[Consult_Payments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consult_Payments];
GO
IF OBJECT_ID(N'[dbo].[Consultations]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consultations];
GO
IF OBJECT_ID(N'[dbo].[Diagnos]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Diagnos];
GO
IF OBJECT_ID(N'[dbo].[Doctors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Doctors];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Cardios]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Cardios];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Constitutionals]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Constitutionals];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Ents]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Ents];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Extrems]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Extrems];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Gastros]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Gastros];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Lymphs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Lymphs];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Muscs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Muscs];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Necks]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Necks];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Neuros]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Neuros];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Respis]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Respis];
GO
IF OBJECT_ID(N'[dbo].[Evaluation_Skins]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Evaluation_Skins];
GO
IF OBJECT_ID(N'[dbo].[ExamCategories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ExamCategories];
GO
IF OBJECT_ID(N'[dbo].[Exams]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Exams];
GO
IF OBJECT_ID(N'[dbo].[ExamTypes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ExamTypes];
GO
IF OBJECT_ID(N'[dbo].[Hereditary_Illnes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hereditary_Illnes];
GO
IF OBJECT_ID(N'[dbo].[Hospital_bed]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hospital_bed];
GO
IF OBJECT_ID(N'[dbo].[Hospital_buildings]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hospital_buildings];
GO
IF OBJECT_ID(N'[dbo].[Hospital_units]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hospital_units];
GO
IF OBJECT_ID(N'[dbo].[Hospital_wards]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Hospital_wards];
GO
IF OBJECT_ID(N'[dbo].[Inpatient_regs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Inpatient_regs];
GO
IF OBJECT_ID(N'[dbo].[Insurance_Payments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Insurance_Payments];
GO
IF OBJECT_ID(N'[dbo].[Insurances]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Insurances];
GO
IF OBJECT_ID(N'[dbo].[Invoices]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Invoices];
GO
IF OBJECT_ID(N'[dbo].[Labs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Labs];
GO
IF OBJECT_ID(N'[dbo].[Medical_Histos]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Medical_Histos];
GO
IF OBJECT_ID(N'[dbo].[Medicaments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Medicaments];
GO
IF OBJECT_ID(N'[dbo].[MedicationReactions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MedicationReactions];
GO
IF OBJECT_ID(N'[dbo].[Newborns]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Newborns];
GO
IF OBJECT_ID(N'[dbo].[Pathologies]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Pathologies];
GO
IF OBJECT_ID(N'[dbo].[Pathology_Categories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Pathology_Categories];
GO
IF OBJECT_ID(N'[dbo].[PatientAllergies]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PatientAllergies];
GO
IF OBJECT_ID(N'[dbo].[Patients]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Patients];
GO
IF OBJECT_ID(N'[dbo].[Payments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Payments];
GO
IF OBJECT_ID(N'[dbo].[PediatricPSCs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PediatricPSCs];
GO
IF OBJECT_ID(N'[dbo].[Perinatal_monitors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Perinatal_monitors];
GO
IF OBJECT_ID(N'[dbo].[Perinatals]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Perinatals];
GO
IF OBJECT_ID(N'[dbo].[Prescriptions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Prescriptions];
GO
IF OBJECT_ID(N'[dbo].[Puerperium_monitors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Puerperium_monitors];
GO
IF OBJECT_ID(N'[dbo].[Surgeries]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Surgeries];
GO
IF OBJECT_ID(N'[dbo].[SystemReviews]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SystemReviews];
GO
IF OBJECT_ID(N'[dbo].[Vaccinations]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Vaccinations];
GO
IF OBJECT_ID(N'[dbo].[WorkFlows]', 'U') IS NOT NULL
    DROP TABLE [dbo].[WorkFlows];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Appointments'
CREATE TABLE [dbo].[Appointments] (
    [Apointment_id] int IDENTITY(1,1) NOT NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [Appointment_Date] datetime  NULL,
    [Comments] varchar(max)  NULL,
    [Appointment_Validity_Date] datetime  NULL,
    [Validity_Status] varchar(16)  NULL,
    [Urgency] varchar(16)  NULL,
    [Description] varchar(64)  NOT NULL,
    [Patient_Id] int  NULL,
    [Doctor_Id] int  NULL
);
GO

-- Creating table 'BodyRegions'
CREATE TABLE [dbo].[BodyRegions] (
    [BodyRegion_id] int IDENTITY(1,1) NOT NULL,
    [BodyRegion_Name] nvarchar(50)  NULL,
    [Exam_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Charges'
CREATE TABLE [dbo].[Charges] (
    [Charge_Id] int IDENTITY(1,1) NOT NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [Date] datetime  NULL,
    [Charge_Amount] float  NULL,
    [Balance_Due] float  NULL,
    [Insurance_Balance] float  NULL,
    [Charge_Document_Info] varchar(200)  NOT NULL,
    [Charge_Reason] varchar(200)  NOT NULL,
    [Invoice_ID] int  NULL
);
GO

-- Creating table 'ClinicCharts'
CREATE TABLE [dbo].[ClinicCharts] (
    [ClinicChart_Id] int IDENTITY(1,1) NOT NULL,
    [Clinic_Chart_Description] varchar(200)  NOT NULL,
    [Clinic_Chart_Extra_info] varchar(200)  NOT NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Consult_Payments'
CREATE TABLE [dbo].[Consult_Payments] (
    [Consult_Payment_id] int IDENTITY(1,1) NOT NULL,
    [Fee_Date] datetime  NULL,
    [Fee_Charge] decimal(19,4)  NULL,
    [Fee_Paid] decimal(19,4)  NULL,
    [Fee_Due] decimal(19,4)  NULL,
    [Consultation_id] int  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Consultations'
CREATE TABLE [dbo].[Consultations] (
    [Consultation_id] int IDENTITY(1,1) NOT NULL,
    [Temperature] int  NULL,
    [Blood_Pressure_Systolic] int  NULL,
    [Blood_Pressure_Diastolic] int  NULL,
    [Pulse] int  NULL,
    [Respiratory_Rate] int  NULL,
    [Pain] varchar(20)  NULL,
    [Height] int  NULL,
    [Weight] int  NULL,
    [Pregnant] bit  NULL,
    [Date] datetime  NULL,
    [Time_In] datetime  NULL,
    [Time_Out] datetime  NULL,
    [Location] nvarchar(255)  NULL,
    [Severity] nvarchar(255)  NULL,
    [Disposition] nvarchar(255)  NULL,
    [Diagnosis] nvarchar(255)  NULL,
    [Clinical_Notes] nvarchar(255)  NULL,
    [Patient_recomendations] nvarchar(255)  NULL,
    [Purpose] varchar(200)  NULL,
    [Heart_Rate] int  NULL,
    [Cholesterol] int  NULL,
    [HDL] int  NULL,
    [Triglicerides] int  NULL,
    [LDL] int  NULL,
    [Glycemia] int  NULL,
    [Addominal_Circunference] int  NULL,
    [Frequently_Thirsty] bit  NULL,
    [Frequently_Hungry] bit  NULL,
    [Frequently_Urination] bit  NULL,
    [Chest_Pain] bit  NULL,
    [Chest_pain_on_exercise_only] bit  NULL,
    [Stressed_out] bit  NULL,
    [Sudden_Weight_change] bit  NULL,
    [Easily_Bruised_or_Bleeding] bit  NULL,
    [Feels_tired] bit  NULL,
    [Dificulty_Breathing] bit  NULL,
    [Frequently_Headaches] bit  NULL,
    [Memory_loss] bit  NULL,
    [Fainting_Episode] bit  NULL,
    [Blurry_Vision] bit  NULL,
    [Mood_Swings] bit  NULL,
    [Other_Symptoms] varchar(max)  NULL,
    [Directions_Next_Consult] datetime  NULL,
    [Doctor_for_next_Appointment] varchar(100)  NOT NULL,
    [Directions_Medical_Advice] nvarchar(max)  NULL,
    [Doctor_Id] int  NULL,
    [Recent_Antibiotic_use] bit  NULL,
    [Recent_Oral_steroid_use] bit  NULL,
    [Recent_ER_Visit] bit  NULL,
    [Recent_Weight_loss_or_decreased_appetite] bit  NULL,
    [Recent_Hospital_admission] bit  NULL,
    [Planned_air_travel_in_near_future] bit  NULL,
    [Spirometry_evaluation_performed_within_previous_12_months] bit  NULL,
    [Asymptomatic_with_usual_activity] bit  NULL,
    [Symptomatic_with_usual_activity] bit  NULL,
    [Symptomatic_with_minimal_activity] bit  NULL,
    [Symptomatic_at_rest] bit  NULL,
    [at_risk] bit  NULL,
    [Mild] bit  NULL,
    [Moderate] bit  NULL,
    [Severe] bit  NULL,
    [Very_Severe] bit  NULL,
    [Increased_cough] bit  NULL,
    [increased_dyspnea] bit  NULL,
    [increased_sputum_production] bit  NULL,
    [Current_Medications_were_reviewed] bit  NULL,
    [Medication_Notes] varchar(250)  NULL,
    [Allergy_List_reviewed] bit  NULL,
    [Food_or_Drug_Allergies] bit  NULL,
    [Allergies_Notes] varchar(250)  NULL,
    [Current_Illness_Notes] varchar(250)  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Diagnos'
CREATE TABLE [dbo].[Diagnos] (
    [Diagno_Id] int IDENTITY(1,1) NOT NULL,
    [Date] datetime  NULL,
    [Description] varchar(max)  NULL,
    [Status] varchar(50)  NOT NULL,
    [Doctor_Id] int  NULL,
    [Patient_Id] int  NULL,
    [Consultation_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Doctors'
CREATE TABLE [dbo].[Doctors] (
    [Doctor_Id] int IDENTITY(1,1) NOT NULL,
    [Doctor_Name] nvarchar(max)  NOT NULL,
    [Title] varchar(10)  NULL,
    [Initials] varchar(5)  NULL,
    [First_Name] varchar(50)  NULL,
    [Middle_Name] varchar(50)  NULL,
    [Last_Name] varchar(50)  NULL,
    [Licence_Number] varchar(50)  NULL,
    [Degrees] varchar(max)  NULL,
    [Date_of_Birth] datetime  NULL,
    [AFP_Number] varchar(50)  NULL,
    [NUP_Number] varchar(50)  NULL,
    [ISSS_Number] varchar(50)  NULL,
    [NIT_Number] varchar(50)  NULL,
    [DUI_Number] varchar(50)  NULL,
    [Specialities] varchar(150)  NULL,
    [Address1] varchar(50)  NULL,
    [Address2] varchar(50)  NULL,
    [Colonia] varchar(50)  NULL,
    [Municipio] varchar(50)  NULL,
    [Departamento] varchar(50)  NULL,
    [Pais] varchar(50)  NULL,
    [Phone_Home_1] varchar(50)  NULL,
    [Phone_Home_2] varchar(50)  NULL,
    [Phone_Cell_1] varchar(50)  NULL,
    [Phone_Cell_2] varchar(50)  NULL,
    [Other_Phone] varchar(50)  NULL,
    [Fax] varchar(50)  NULL,
    [Email_Personal] varchar(50)  NULL,
    [Pay_By_Percent] bit  NULL,
    [Pay_By_Percent_Value] decimal(10,4)  NULL,
    [Pay_By_Amount] bit  NULL,
    [Pay_By_Amount_Value] decimal(19,4)  NULL,
    [Hourly_Rate] decimal(19,4)  NULL,
    [Photo] varbinary(max)  NULL,
    [Spouse_Name] varchar(50)  NULL,
    [Spouse_Phone] varchar(50)  NULL,
    [Spouse_Email] varchar(50)  NULL,
    [Signature] varbinary(max)  NULL,
    [Position_Held] varchar(50)  NULL,
    [Resposabilities] varchar(max)  NULL,
    [Supervisor] varchar(50)  NULL,
    [Working_here_since] datetime  NULL,
    [Email_Work] varchar(50)  NOT NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Cardios'
CREATE TABLE [dbo].[Evaluation_Cardios] (
    [Evaluation_CV_id] int IDENTITY(1,1) NOT NULL,
    [Clear_S1_S2] bit  NULL,
    [No_murmur_rub_or_gallop] bit  NULL,
    [Gallop_Audible] bit  NULL,
    [Rub_audible] bit  NULL,
    [Murmur_present] bit  NULL,
    [Murmur_Systolic] bit  NULL,
    [Murmur_Diastolic] bit  NULL,
    [Grade_I] bit  NULL,
    [Grade_II] bit  NULL,
    [Grade_III] bit  NULL,
    [Grade_IV] bit  NULL,
    [Grade_V] bit  NULL,
    [Grade_VI] bit  NULL,
    [Peripheral_pulse_palpable] bit  NULL,
    [Peripheral_pulse_Absent] bit  NULL,
    [Peripheral_pulse_Weak] bit  NULL,
    [Evaluation_Cardio_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Constitutionals'
CREATE TABLE [dbo].[Evaluation_Constitutionals] (
    [Evaluation_Cons_id] int IDENTITY(1,1) NOT NULL,
    [Height] int  NULL,
    [Weight] int  NULL,
    [Temperature] int  NULL,
    [Pulse_Rate] int  NULL,
    [Rhythm_Regular] bit  NULL,
    [Rhythm_lrregular] bit  NULL,
    [Blood_Pressure_sitting] int  NULL,
    [Blood_Pressure_standing] int  NULL,
    [Blood_Pressure_lying] int  NULL,
    [Respiratory_Rate] int  NULL,
    [Evaluation_Const_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Ents'
CREATE TABLE [dbo].[Evaluation_Ents] (
    [Evaluation_Ent_id] int IDENTITY(1,1) NOT NULL,
    [Nasal_mucosa_septum_and_turbinates_WNL] bit  NULL,
    [Nasal_mucosa_septum_and_turbinates_Edema_or_erythema_present] bit  NULL,
    [Dentition_and_gums_WNL] bit  NULL,
    [Dental_caries] bit  NULL,
    [Gingivitis] bit  NULL,
    [Oropharynx_WNL] bit  NULL,
    [Oropharynx_Edema_or_Erythema_present] bit  NULL,
    [Oral_ulcers] bit  NULL,
    [Oral_Petechiae] bit  NULL,
    [Maliampati_I] bit  NULL,
    [Maliampati_II] bit  NULL,
    [Maliampati_III] bit  NULL,
    [Maliampati_IV] bit  NULL,
    [Evaluation_Ent_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Extrems'
CREATE TABLE [dbo].[Evaluation_Extrems] (
    [Evaluation_Extrem_id] int IDENTITY(1,1) NOT NULL,
    [Extremities_WNL] bit  NULL,
    [Clubbing] bit  NULL,
    [Cyanosis] bit  NULL,
    [Petechiae] bit  NULL,
    [Synovitis] bit  NULL,
    [E_Right] bit  NULL,
    [E_Left] bit  NULL,
    [Value] varchar(30)  NULL,
    [Evaluation_Extrem_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Gastros'
CREATE TABLE [dbo].[Evaluation_Gastros] (
    [Evaluation_Gastro_id] int IDENTITY(1,1) NOT NULL,
    [Abdomen_WNL] bit  NULL,
    [Mass_present_LUQ] bit  NULL,
    [Mass_present_RUQ] bit  NULL,
    [Mass_present_LLQ] bit  NULL,
    [Mass_present_RLQ] bit  NULL,
    [Value] varchar(30)  NULL,
    [Pulsatile] bit  NULL,
    [Liver_and_spleen_palpitation_WNL] bit  NULL,
    [Unable_To_palpate_Liver] bit  NULL,
    [Unable_To_palpate_Spleen] bit  NULL,
    [Enlarged_Liver] bit  NULL,
    [Enlarged_spleen] bit  NULL,
    [Evaluation_Gastro_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Lymphs'
CREATE TABLE [dbo].[Evaluation_Lymphs] (
    [Evaluation_Lymph_id] int IDENTITY(1,1) NOT NULL,
    [Lymph_node_exam_WNL] bit  NULL,
    [Examined_Neck] bit  NULL,
    [Examined_Axila] bit  NULL,
    [Examined_Groin] bit  NULL,
    [Examined_Other] bit  NULL,
    [Examined_Other_value] varchar(25)  NULL,
    [Lymphadenopathy_noted_in_Neck] bit  NULL,
    [Lymphadenopathy_noted_in_Axila] bit  NULL,
    [Lymphadenopathy_noted_in_Groin] bit  NULL,
    [Lymphadenopathy_noted_in_Other] bit  NULL,
    [Lymphadenopathy_noted_in_Other_value] varchar(25)  NULL,
    [Evaluation_Lymph_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Muscs'
CREATE TABLE [dbo].[Evaluation_Muscs] (
    [Evaluation_Musc_id] int IDENTITY(1,1) NOT NULL,
    [Muscle_tone_WNL] bit  NULL,
    [Tone_is_increased] bit  NULL,
    [Tone_is_decreased] bit  NULL,
    [Atrophy_present] bit  NULL,
    [Gait_and_station_WNL] bit  NULL,
    [Ataxia] bit  NULL,
    [Wide_based_gait] bit  NULL,
    [Shuffle] bit  NULL,
    [Patient_leans_Right] bit  NULL,
    [Patient_leans_Left] bit  NULL,
    [Patient_leans_Front] bit  NULL,
    [Patient_leans_Back] bit  NULL,
    [Evaluation_Musc_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Necks'
CREATE TABLE [dbo].[Evaluation_Necks] (
    [Evaluation_Neck_id] int IDENTITY(1,1) NOT NULL,
    [Neck_WNL] bit  NULL,
    [Erythema_or_scarring_Consistent_with] bit  NULL,
    [Old_Radiation_dermatitis] bit  NULL,
    [Thyroid_WNL] bit  NULL,
    [Thyromegaly] bit  NULL,
    [Nodules_Palpable] bit  NULL,
    [Neck_mass] bit  NULL,
    [Neck_mass_value] varchar(30)  NULL,
    [Jugular_Veins_WNL] bit  NULL,
    [JVD_Present] bit  NULL,
    [a_v_or_cannon_a_waves_present] bit  NULL,
    [Recent_Radiation_dermatitis] bit  NULL,
    [Evaluation_Neck_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Neuros'
CREATE TABLE [dbo].[Evaluation_Neuros] (
    [Evaluation_Neuro_id] int IDENTITY(1,1) NOT NULL,
    [Oriented] bit  NULL,
    [Not_oriented_to_person] bit  NULL,
    [Not_oriented_to_time] bit  NULL,
    [Not_oriented_to_place] bit  NULL,
    [Affect_is_WNL] bit  NULL,
    [Patient_appears_Agitated] bit  NULL,
    [Patient_appears_Anxious] bit  NULL,
    [Patient_appears_Depressed] bit  NULL,
    [Evaluation_Neuro_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Respis'
CREATE TABLE [dbo].[Evaluation_Respis] (
    [Evaluation_Resp_id] int IDENTITY(1,1) NOT NULL,
    [Chest_is_free_of_defects_Expands_Normally_and_Symmetrically] bit  NULL,
    [Erythema_Consistent_with_Radiation_Dermatitis] bit  NULL,
    [Scarring_consistent_with_old_healed_radiation_dermatitis] bit  NULL,
    [Surgical_scar_present] bit  NULL,
    [other_Scar] bit  NULL,
    [Resp_effort_WNL] bit  NULL,
    [Accessory_muscle_use] bit  NULL,
    [Intercostal_retractions] bit  NULL,
    [Paradoxic_movements] bit  NULL,
    [Chest_percussion_WNL] bit  NULL,
    [Dullness_to_percussion] bit  NULL,
    [Dull_Lt] bit  NULL,
    [Dull_Rt] bit  NULL,
    [Hyperresonance] bit  NULL,
    [Hyper_Lt] bit  NULL,
    [Hyper_Rt] bit  NULL,
    [Tactile_fremitus_WNL] bit  NULL,
    [Tactile_Changed_Value] varchar(30)  NULL,
    [Auscultation_WNL] bit  NULL,
    [Bronchial_breath_sounds] bit  NULL,
    [Egophony] bit  NULL,
    [rales] bit  NULL,
    [Rhonchi] bit  NULL,
    [Wheezes] bit  NULL,
    [Rub_present] bit  NULL,
    [other_Scar_desc] varchar(100)  NULL,
    [Tactile_fremitus_Increased] bit  NULL,
    [Tactile_fremitus_Decreased] bit  NULL,
    [Evaluation_Resp_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Evaluation_Skins'
CREATE TABLE [dbo].[Evaluation_Skins] (
    [Evaluation_Skin_id] int IDENTITY(1,1) NOT NULL,
    [Skin_WNL] bit  NULL,
    [Ecchymoses] bit  NULL,
    [Rash] bit  NULL,
    [Bullae] bit  NULL,
    [Pressure_Ulcer_Stage_1] bit  NULL,
    [Pressure_Ulcer_Stage_2] bit  NULL,
    [Pressure_Ulcer_Stage_3] bit  NULL,
    [Pressure_Ulcer_Stage_4] bit  NULL,
    [Other_Skin_Disease] bit  NULL,
    [Other_Skin_Disease_Value] varchar(50)  NULL,
    [Evaluation_Skin_Notes] varchar(max)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'ExamCategories'
CREATE TABLE [dbo].[ExamCategories] (
    [ExamCategory_id] int IDENTITY(1,1) NOT NULL,
    [Category_Name] nvarchar(255)  NULL,
    [ExamType_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Exams'
CREATE TABLE [dbo].[Exams] (
    [Exam_id] int  NOT NULL,
    [Date] datetime  NULL,
    [Description] varchar(50)  NULL,
    [Results] varchar(max)  NULL,
    [Summary] varchar(max)  NULL,
    [Reason] varchar(50)  NULL,
    [Status] varchar(50)  NULL,
    [Scan_Image] varbinary(max)  NULL,
    [Done_and_ready] bit  NULL,
    [Type] varchar(50)  NOT NULL,
    [Diagno_Id] int  NULL,
    [Doctor_Id] int  NULL,
    [Consultation_id] int  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'ExamTypes'
CREATE TABLE [dbo].[ExamTypes] (
    [ExamType_id] int IDENTITY(1,1) NOT NULL,
    [Type_Name] nvarchar(255)  NULL,
    [ResultType] nvarchar(255)  NULL,
    [Exam_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Hereditary_Illnes'
CREATE TABLE [dbo].[Hereditary_Illnes] (
    [Hereditary_Illnesses_Id] int IDENTITY(1,1) NOT NULL,
    [Asthma] bit  NULL,
    [Autism] bit  NULL,
    [Multiple_sclerosis] bit  NULL,
    [Cancers] bit  NULL,
    [Ciliopathies] bit  NULL,
    [Cleft_palate] bit  NULL,
    [Diabetes] bit  NULL,
    [Heart_disease] bit  NULL,
    [Hypertension] bit  NULL,
    [Inflammatory_bowel_disease] bit  NULL,
    [Mental_retardation] bit  NULL,
    [Obesity] bit  NULL,
    [Hypothyroidism] bit  NULL,
    [Coronary_artery_disease] bit  NULL,
    [Thrombotic_disorder] bit  NULL,
    [Colon_cancer] bit  NULL,
    [Breast_cancer_or_ovarian_cancer] bit  NULL,
    [Alzheimers_disease] bit  NULL,
    [Cri_du_chat_syndrome] bit  NULL,
    [Down_syndrome] bit  NULL,
    [Cystic_fibrosis] bit  NULL,
    [COPD_Chronic_Obstructive_Pulmonary_Disease] bit  NULL,
    [Pancreatitis] bit  NULL,
    [Peripheral_Artery_Disease] bit  NULL,
    [Renal_Dysfunction] bit  NULL,
    [Thyroid_Disease] bit  NULL,
    [Other] bit  NULL,
    [Other_description] varchar(50)  NULL,
    [ClinicChart_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Hospital_bed'
CREATE TABLE [dbo].[Hospital_bed] (
    [Hospital_bed_Id] int IDENTITY(1,1) NOT NULL,
    [State] varchar(16)  NULL,
    [Bed_Type] varchar(16)  NOT NULL,
    [Ward_ID] int  NULL,
    [Telephone_Number] varchar(128)  NULL,
    [Extra_Info] varchar(max)  NULL,
    [Hospital_ward_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Hospital_buildings'
CREATE TABLE [dbo].[Hospital_buildings] (
    [Hospital_Building_Id] int IDENTITY(1,1) NOT NULL,
    [Code] varchar(64)  NULL,
    [Name] varchar(128)  NULL,
    [Institution] int  NULL,
    [Extra_info] varchar(max)  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Hospital_units'
CREATE TABLE [dbo].[Hospital_units] (
    [Hospital_unit_Id] int IDENTITY(1,1) NOT NULL,
    [Description] varchar(64)  NULL,
    [Extra_Info] varchar(max)  NULL,
    [Unit_Name] varchar(128)  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Hospital_wards'
CREATE TABLE [dbo].[Hospital_wards] (
    [Hospital_ward_Id] int IDENTITY(1,1) NOT NULL,
    [AC] bit  NULL,
    [Telephone] bit  NULL,
    [Is_Private] bit  NULL,
    [Has_sofa_for_Guests] bit  NULL,
    [Private_Bathroom] bit  NULL,
    [Has_Bio_Hazard_Disposal] bit  NULL,
    [Refrigerator] bit  NULL,
    [Extra_Info] varchar(max)  NULL,
    [Type_of_Floor] int  NULL,
    [Has_a_TV] bit  NULL,
    [Gender_Privacy] varchar(16)  NOT NULL,
    [Microwave] bit  NULL,
    [State_of_Room] varchar(16)  NULL,
    [Unit_Number] int  NULL,
    [Number_of_beds_In_Hospital] int  NULL,
    [Has_Internet] bit  NULL,
    [Number_of_beds_In_Room] nvarchar(max)  NOT NULL,
    [Hospital_Building_Id] int  NULL,
    [Hospital_unit_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Inpatient_regs'
CREATE TABLE [dbo].[Inpatient_regs] (
    [Inpatient_reg_Id] int IDENTITY(1,1) NOT NULL,
    [Nursing_Plan] varchar(max)  NULL,
    [Info] varchar(max)  NULL,
    [Admission_Reason] int  NULL,
    [Operating_Physician] int  NULL,
    [Admission_Type] varchar(16)  NULL,
    [Hospitalization_Date] datetime  NULL,
    [Attending_Physician] int  NULL,
    [Discharge_Plan] varchar(max)  NULL,
    [State] varchar(16)  NULL,
    [Discharge_Date] datetime  NULL,
    [Hospital_bed_Id] int  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Insurance_Payments'
CREATE TABLE [dbo].[Insurance_Payments] (
    [Insurance_Payment_id] int IDENTITY(1,1) NOT NULL,
    [Name] varchar(50)  NULL,
    [Description] varchar(50)  NULL,
    [Fee_or_Cost] varchar(50)  NULL,
    [Percentage_paid_for_Insurance] decimal(10,4)  NULL,
    [Percentage_paid_for_Patient] decimal(10,4)  NULL,
    [Amount_Insurance] decimal(19,4)  NULL,
    [Amount_Patient] decimal(19,4)  NULL,
    [Insurance_ID] int  NOT NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Insurances'
CREATE TABLE [dbo].[Insurances] (
    [Insurance_ID] int IDENTITY(1,1) NOT NULL,
    [Contact_Person_name] varchar(50)  NULL,
    [Contact_Person_Midle] varchar(50)  NULL,
    [Contact_Person_Last] varchar(50)  NULL,
    [Department_or_Title] varchar(50)  NULL,
    [Address1] varchar(50)  NULL,
    [Address2] varchar(50)  NULL,
    [City] varchar(50)  NULL,
    [Municipio] varchar(50)  NULL,
    [Departamento] varchar(50)  NULL,
    [Phone1] varchar(50)  NULL,
    [Phone2] varchar(50)  NULL,
    [Fax] varchar(50)  NULL,
    [Email] varchar(50)  NULL,
    [Group] varchar(50)  NULL,
    [Vender_Number] varchar(50)  NULL,
    [Referral_Number] varchar(50)  NULL,
    [Claim_Number] varchar(50)  NULL,
    [Payor_ID_Number] varchar(50)  NULL,
    [Licence_Number] varchar(50)  NULL,
    [Account_Number] varchar(50)  NULL,
    [Billing_Method] varchar(50)  NULL,
    [Notes] varchar(max)  NULL,
    [Numero_NIT] varchar(50)  NULL,
    [Registro_IVA] varchar(50)  NULL,
    [Insurance_Type] varchar(50)  NULL,
    [Consultation_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Invoices'
CREATE TABLE [dbo].[Invoices] (
    [Invoice_ID] int IDENTITY(1,1) NOT NULL,
    [Date] datetime  NOT NULL,
    [Description] varchar(200)  NOT NULL,
    [Paid] float  NULL,
    [Duration] time  NULL,
    [Rate] float  NULL,
    [Billed] float  NULL,
    [Balance] float  NULL,
    [Payment] float  NULL,
    [Late_Fee] float  NULL,
    [Balance_Due_Invoice] float  NULL,
    [Patient_Total_Balance] float  NULL,
    [Insurance_Balance] float  NULL,
    [Patient_Id] int  NULL,
    [Insurance_ID] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Labs'
CREATE TABLE [dbo].[Labs] (
    [Lab_id] int IDENTITY(1,1) NOT NULL,
    [Date_Requested] datetime  NULL,
    [Description] varchar(128)  NULL,
    [Pathologist] int  NULL,
    [Date_Analysis] datetime  NULL,
    [Results] varchar(max)  NULL,
    [Requestor] int  NULL,
    [Patient_Id] int  NULL,
    [Doctor_Id] int  NULL,
    [Exam_id] int  NULL,
    [Diagno_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Medical_Histos'
CREATE TABLE [dbo].[Medical_Histos] (
    [Medical_History_Id] int IDENTITY(1,1) NOT NULL,
    [Asthma] bit  NULL,
    [Adrenal_dysfunction] bit  NULL,
    [Arthritis] bit  NULL,
    [Blood_clots] bit  NULL,
    [COPD] bit  NULL,
    [Coronary_Artery_Disease] bit  NULL,
    [Cystic_Fibrosis] bit  NULL,
    [Diabetes] bit  NULL,
    [Diabetes1] bit  NULL,
    [Diabetes2] bit  NULL,
    [Endocarditis] bit  NULL,
    [GERD] bit  NULL,
    [Gout] bit  NULL,
    [Hemolytic_anemia] bit  NULL,
    [Hepatic_dysfunction] bit  NULL,
    [HIV_AIDS] bit  NULL,
    [Hypertension] bit  NULL,
    [Inflammatory_Bowel_Disease] bit  NULL,
    [Neuromuscular_weakness] bit  NULL,
    [Osteoporosis] bit  NULL,
    [Organ_transplant] bit  NULL,
    [Pancreatitis] bit  NULL,
    [Peripheral_Artery_Disease] bit  NULL,
    [Pituitary_infarct_or_hemorrhage] bit  NULL,
    [Renal_dysfunction] bit  NULL,
    [Hemodialysis] bit  NULL,
    [Peritoneal_dialysis] bit  NULL,
    [Sarcoidosis] bit  NULL,
    [Seizure_disorder] bit  NULL,
    [Sleep_Apnea_] bit  NULL,
    [Systemic_Lupus_Erythematosis] bit  NULL,
    [Thrombocytopenia] bit  NULL,
    [Thyroid_disease] bit  NULL,
    [Thyroid_hypo] bit  NULL,
    [Thyroid_hyper] bit  NULL,
    [Chemotherapy] bit  NULL,
    [Colonoscopy] bit  NULL,
    [ECHO_Stress_test] bit  NULL,
    [Immunosuppressive_therapy] bit  NULL,
    [Mammogram] bit  NULL,
    [Organ_failure] bit  NULL,
    [PFTs] bit  NULL,
    [Pap_Smear] bit  NULL,
    [Prior_intubations] bit  NULL,
    [Sleep_study] bit  NULL,
    [Steroid_use_Pain] bit  NULL,
    [Steroid_Use_for_other] bit  NULL,
    [Tuberculosis] bit  NULL,
    [Tuberculosis_Treatment] bit  NULL,
    [Surgical_Resection] bit  NULL,
    [Radio_ablation] bit  NULL,
    [Last_Chemotherapy] datetime  NULL,
    [Last_cTx] datetime  NULL,
    [Radiation] bit  NULL,
    [Last_rTX] bit  NULL,
    [CABG] bit  NULL,
    [Splenectomy] bit  NULL,
    [Lung_resection] bit  NULL,
    [Pleurodesis] bit  NULL,
    [Other_Surgery] bit  NULL,
    [Smoke_Yes] bit  NULL,
    [Ever_smoker] bit  NULL,
    [Num_Packs_per_day] tinyint  NULL,
    [Num_Cigarettes_per_day] tinyint  NULL,
    [Willing_to_quit_Tobacco] bit  NULL,
    [Nicotine_replacement] bit  NULL,
    [Buproprion_or_nortriptyline] bit  NULL,
    [Nicotine_receptor_blockade] bit  NULL,
    [Quit_Tobacco_date] datetime  NULL,
    [Alcohol_Use] bit  NULL,
    [Num_Drinks_per_day] tinyint  NULL,
    [Num_Drinks_Per_week] tinyint  NULL,
    [Willing_to_quit_Alcohol] bit  NULL,
    [Recreational_Drug_Use] bit  NULL,
    [Drug_Inhalation] bit  NULL,
    [Drug_Injection] bit  NULL,
    [Drug_Ingestion] bit  NULL,
    [Willing_to_quit_Drugs_Rec] bit  NULL,
    [Drug_Dependency] bit  NULL,
    [Narcotics] bit  NULL,
    [Benzodiazepines] bit  NULL,
    [Willing_to_quit_Medicated_Drugs] bit  NULL,
    [Inorganic_dust] bit  NULL,
    [Organic_dust] bit  NULL,
    [Noxious_fumes] bit  NULL,
    [Military_Experience] bit  NULL,
    [Chemical_or_fires] bit  NULL,
    [ClinicChart_Id] int  NOT NULL,
    [Arthritis_RA] bit  NULL,
    [Blood_clots_DVT] bit  NULL,
    [Blood_clots_PE] bit  NULL,
    [Congestive_Heart_Failure] bit  NULL,
    [Diabetes_Type_1] bit  NULL,
    [Diabetes_Type_2] bit  NULL,
    [Achalasia] bit  NULL,
    [Antibiotic_use] bit  NULL,
    [Arteriovenous_Malformations] bit  NULL,
    [Autoimmune_hepatitis] bit  NULL,
    [Barretts_esophagus] bit  NULL,
    [Budd_Chiari_Syndrome] bit  NULL,
    [Carcinoid_Syndrome] bit  NULL,
    [C_difficile_Colitis] bit  NULL,
    [Celiac_Disease] bit  NULL,
    [Cirrhosis] bit  NULL,
    [Colitis] bit  NULL,
    [Crohn_Disease] bit  NULL,
    [Diverticulitis] bit  NULL,
    [Diverticulosis] bit  NULL,
    [Esophageal_Stricture] bit  NULL,
    [Esophageal_Varices] bit  NULL,
    [Familial_Mediterranean_Fever] bit  NULL,
    [Cholelithiasis] bit  NULL,
    [Cholecystitis] bit  NULL,
    [Ischemic_colitis] bit  NULL,
    [Hemochromatosis] bit  NULL,
    [Hemorrhoids] bit  NULL,
    [Hepatitis] bit  NULL,
    [Herpes] bit  NULL,
    [Hernia] bit  NULL,
    [Histiocytosis] bit  NULL,
    [H_pylori_positive] bit  NULL,
    [Jaundice] bit  NULL,
    [Liver_disease] bit  NULL,
    [Malaria] bit  NULL,
    [Nonalcoholic_Fatty_Liver_Disease] bit  NULL,
    [Parasitic_infections] bit  NULL,
    [Peritonitis] bit  NULL,
    [Polyps] bit  NULL,
    [Sclerosing_cholangitis] bit  NULL,
    [Sickle_Cell_Disease] bit  NULL,
    [Ulcerative_colitis] bit  NULL,
    [Ulcers] bit  NULL,
    [Vl_Poma] bit  NULL,
    [Whipple_s_disease] bit  NULL,
    [Wilson_s_Disease] bit  NULL,
    [Zollinger_Ellison_Syndrome] bit  NULL,
    [Full_Colectomy] bit  NULL,
    [Partial_Colectomy] bit  NULL,
    [Esophageal_dilation] bit  NULL,
    [Gastric_bypass] bit  NULL,
    [Gastric_volume_reduction] bit  NULL,
    [Malignant_Liver_biopsy] bit  NULL,
    [Benign_Liver_biopsy] bit  NULL,
    [Pancreatic_stent] bit  NULL,
    [PEG_PEJ_tube] bit  NULL,
    [Malignant_Polypectomy] bit  NULL,
    [Benign_Polypectomy] bit  NULL,
    [Arrhythmias] bit  NULL,
    [Heart_Failure] bit  NULL,
    [Anxiety] bit  NULL,
    [Bipolar_disorder] bit  NULL,
    [Depression] bit  NULL,
    [Mania] bit  NULL,
    [Psychosis] bit  NULL,
    [Schizophrenia] bit  NULL,
    [Personality_disorder] bit  NULL,
    [Porphyria] bit  NULL,
    [Seizures] bit  NULL,
    [Syphilis] bit  NULL,
    [Hospitalizations_for_psychiatric_illnesses] bit  NULL,
    [History_of_Electroconvulsive_Shock_Therapy] bit  NULL,
    [Prior_Suicide_attempts] bit  NULL,
    [Current_Suicide_attempts] bit  NULL,
    [Suicidal_ideation] bit  NULL,
    [Homicidal_Ideation] bit  NULL,
    [Neoroleptic_Malignant_Syndrome] bit  NULL,
    [Malignant_Hyperthermia] bit  NULL,
    [Protein_deficiency_C] bit  NULL,
    [Protein_deficiency_S] bit  NULL,
    [Renal_dysfunction_ESRD] bit  NULL,
    [Sleep_Apnea] bit  NULL,
    [Sleep_Apnea_CPAP] bit  NULL,
    [Sleep_Apnea_BiPAP] bit  NULL,
    [Thrombocytopenia_ITP] bit  NULL,
    [Thrombocytopenia_TTP] bit  NULL,
    [Thyroid_disease_hypo] bit  NULL,
    [Thyroid_disease_hyper] bit  NULL,
    [Tuberculosis_PPD] bit  NULL,
    [Tuberculosis_Test_Positive] bit  NULL,
    [Tuberculosis_Test_Negative] bit  NULL,
    [Tuberculosis_Test_Date] bit  NULL,
    [Malignancy_Colon] bit  NULL,
    [Malignancy_Leukemia_Lymphoma] bit  NULL,
    [Malignancy_Melanoma] bit  NULL,
    [Malignancy_Renal_cell] bit  NULL,
    [Malignancy_Pituitary] bit  NULL,
    [Malignancy_Prostate] bit  NULL,
    [Malignancy_Testicular] bit  NULL,
    [Malignancy_Breast] bit  NULL,
    [Malignancy_Colorectal] bit  NULL,
    [Malignancy_Hepatic] bit  NULL,
    [Malignancy_Lung] bit  NULL,
    [Malignancy_Thyroid] bit  NULL,
    [Malignancy_Other] bit  NULL,
    [Radiation_Exposure] bit  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Medicaments'
CREATE TABLE [dbo].[Medicaments] (
    [Medicament_id] int IDENTITY(1,1) NOT NULL,
    [Indications] varchar(max)  NULL,
    [Name] int  NULL,
    [Overdosage] varchar(max)  NULL,
    [Pregnancy_Warning] bit  NULL,
    [Notes] varchar(max)  NULL,
    [Therapeutic_Action] varchar(128)  NULL,
    [Storage] varchar(max)  NULL,
    [Adverse_reaction] varchar(max)  NULL,
    [Dosage] varchar(max)  NULL,
    [Active_Component] varchar(128)  NULL,
    [Pregnancy] varchar(max)  NULL,
    [Presentation] varchar(max)  NULL,
    [Composition] varchar(max)  NULL,
    [Laboratory] varchar(200)  NOT NULL,
    [Contact_Person] varchar(200)  NOT NULL,
    [Prescription_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'MedicationReactions'
CREATE TABLE [dbo].[MedicationReactions] (
    [MedicationReaction_Id] int IDENTITY(1,1) NOT NULL,
    [Medication_Name] varchar(100)  NULL,
    [Active_Ingredient] varchar(300)  NULL,
    [More_Brand_Names] varchar(300)  NULL,
    [Last_Known_Reaction_Description] varchar(350)  NULL,
    [Dosage_taken_for_Reaction] varchar(50)  NULL,
    [Date_of_Reaction] datetime  NULL,
    [Reaction_Notes] varchar(350)  NULL,
    [RecallConbinationWithOtherDrug] varchar(100)  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Newborns'
CREATE TABLE [dbo].[Newborns] (
    [Newborn_id] int IDENTITY(1,1) NOT NULL,
    [create_date] varchar(250)  NULL,
    [code] nvarchar(64)  NOT NULL,
    [weight] int  NULL,
    [photo] varbinary(max)  NULL,
    [sex] nvarchar(16)  NOT NULL,
    [reanimation_aspiration] bit  NULL,
    [cephalic_perimeter] int  NULL,
    [test_toxo] bit  NULL,
    [reanimation_mask] bit  NULL,
    [responsible] int  NULL,
    [dismissed] datetime  NULL,
    [reanimation_stimulation] bit  NULL,
    [reanimation_intubation] bit  NULL,
    [reanimation_oxygen] bit  NULL,
    [tod] datetime  NULL,
    [bd] bit  NULL,
    [meconium] bit  NULL,
    [test_billirubin] bit  NULL,
    [test_chagas] bit  NULL,
    [name] nvarchar(128)  NULL,
    [notes] varchar(max)  NULL,
    [test_audition] bit  NULL,
    [test_metabolic] bit  NULL,
    [died_at_delivery] bit  NULL,
    [length] int  NULL,
    [died_being_transferred] bit  NULL,
    [cod] int  NULL,
    [test_vdrl] bit  NULL,
    [died_at_the_hospital] bit  NULL,
    [birth_date] datetime  NOT NULL,
    [apgar5] int  NULL,
    [apgar1] int  NULL,
    [Perinatal_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Pathologies'
CREATE TABLE [dbo].[Pathologies] (
    [Pathology_id] int IDENTITY(1,1) NOT NULL,
    [info] varchar(max)  NULL,
    [code] nvarchar(5)  NULL,
    [name] nvarchar(128)  NULL,
    [protein] nvarchar(128)  NULL,
    [gene] nvarchar(128)  NULL,
    [chromosome] nvarchar(128)  NULL,
    [Consultation_id] int  NULL,
    [Pat_category_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [create_date] varchar(250)  NULL
);
GO

-- Creating table 'Pathology_Categories'
CREATE TABLE [dbo].[Pathology_Categories] (
    [Pat_category_Id] int IDENTITY(1,1) NOT NULL,
    [create_date] varchar(250)  NULL,
    [active] bit  NULL,
    [name] nvarchar(128)  NOT NULL,
    [create_uid] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'PatientAllergies'
CREATE TABLE [dbo].[PatientAllergies] (
    [PatientAllergy_id] int IDENTITY(1,1) NOT NULL,
    [KnownAllergy_Description] varchar(250)  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Patients'
CREATE TABLE [dbo].[Patients] (
    [Patient_Id] int IDENTITY(1,1) NOT NULL,
    [First_Name] varchar(50)  NULL,
    [Last_Name] varchar(50)  NULL,
    [HomePhoneNumber] varchar(20)  NULL,
    [WorkPhoneNumber] varchar(20)  NULL,
    [CellPhoneNumber] varchar(20)  NULL,
    [PersonalEmail] varchar(40)  NULL,
    [WorkEmail] varchar(40)  NULL,
    [Address1] varchar(100)  NULL,
    [Address2] varchar(100)  NULL,
    [Colonia] varchar(40)  NULL,
    [Municipio] varchar(40)  NULL,
    [Department] varchar(40)  NULL,
    [Country] varchar(40)  NULL,
    [Sex_Gender] varchar(50)  NULL,
    [MaritalStatus] varchar(50)  NULL,
    [Family] int  NULL,
    [Photo] varbinary(max)  NULL,
    [Notes] varchar(350)  NULL,
    [DOB] datetime  NULL,
    [Age] tinyint  NULL,
    [BloodType] varchar(25)  NULL,
    [BloodRh] varchar(10)  NULL,
    [Schedule_Next_Apointment] bit  NULL,
    [Primary_Doctor] varchar(50)  NULL,
    [Referring_Doctor] varchar(50)  NULL,
    [Related_To_Patient] varchar(50)  NULL,
    [Is_Student] bit  NULL,
    [Financial_Status] varchar(50)  NULL,
    [Ciudad] varchar(50)  NOT NULL,
    [Is_Deceased] bit  NULL,
    [Drinks_Alcohol] bit  NULL,
    [Smokes_light] bit  NULL,
    [Smokes_Heavy] bit  NULL,
    [Does_Exercises] bit  NULL,
    [Average_Number_Meals_Day] int  NULL,
    [Average_Soft_Drinks_day] int  NULL,
    [Coffee_Cups_day] int  NULL,
    [Beers_per_Week] int  NULL,
    [Wine_Glasses_per_Week] int  NULL,
    [Liquour_Drinks_Week] int  NULL,
    [Occupation] varchar(200)  NULL,
    [Education] varchar(200)  NULL,
    [Uses_the_Internet] bit  NULL,
    [Uses_Anticonceptives] bit  NULL,
    [Cigarretes_per_day] int  NULL,
    [Urgent_Allergy_Info] varchar(max)  NULL,
    [Patient_Title_Profession] varchar(50)  NULL,
    [ISSS_Number] varchar(50)  NULL,
    [NIT_Number] varchar(50)  NULL,
    [DUI_Number] varchar(50)  NULL,
    [Doctor_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [Deceased_date] datetime  NULL,
    [Ethnic_Group] int  NULL,
    [General_Info] varchar(max)  NULL,
    [Primary_Care_Doctor] int  NULL,
    [Marital_Status] varchar(16)  NULL,
    [Current_Insurance] int  NULL,
    [Critical_Info] varchar(max)  NULL,
    [Pap_Test_Last] datetime  NULL,
    [Fertile] bit  NULL,
    [Menopause] int  NULL,
    [Full_Term] int  NULL,
    [Currently_Pregnant] bit  NULL,
    [Colposcopy_Last] datetime  NULL,
    [Menarche] int  NULL,
    [Pap_Test] bit  NULL,
    [Colposcopy] bit  NULL,
    [Menopausal] bit  NULL,
    [Mammography_Last] datetime  NULL,
    [Abortions] int  NULL,
    [Premature] int  NULL,
    [Mammography] bit  NULL,
    [Breast_Self_Examination] bit  NULL,
    [Second_Hand_Smoker] bit  NULL,
    [Sexuality_Info] varchar(max)  NULL,
    [Sexual_Practices] varchar(16)  NULL,
    [Smoking_Number] int  NULL,
    [Sexual_Partners] varchar(16)  NULL,
    [Eats_Alone] bit  NULL,
    [Home_Safety] bit  NULL,
    [First_Sexual_Encounter] int  NULL,
    [Age_Start_Smoking] int  NULL,
    [Sexual_Preferences] varchar(16)  NULL,
    [Sex_Anal] varchar(16)  NULL,
    [Sexual_Partners_Number] int  NULL,
    [Car_Revisions_Often] bit  NULL,
    [Uses_Helmet] bit  NULL,
    [Sleep_Hours] int  NULL,
    [Number_Of_Meals] int  NULL,
    [Motorcycle_Rider] bit  NULL,
    [Excercise_Minutes_Day] int  NULL,
    [Ex_Smoker] bit  NULL,
    [Lifestyle_Info] varchar(max)  NULL,
    [Likes_to_Diet] bit  NULL,
    [Uses_Anticonceptive] varchar(16)  NULL,
    [Uses_Car_Seat_Belt] bit  NULL,
    [Is_a_Prostitute] bit  NULL,
    [Has_Sex_With_Prostitutes] bit  NULL,
    [Diet_Info] varchar(256)  NULL,
    [Eats_lots_Salt] bit  NULL,
    [Sleep_During_Daytime] bit  NULL,
    [Drug_Usage] bit  NULL,
    [Prison_Current] bit  NULL,
    [Lives_in_Hostile_Area] bit  NULL,
    [Has_Electricity] bit  NULL,
    [Is_Single_Parent] bit  NULL,
    [Average_Income] varchar(16)  NULL,
    [Works_Around_Gas] bit  NULL,
    [Prison_in_Past] bit  NULL,
    [Suffers_Domestic_Violence] bit  NULL,
    [Has_Television] bit  NULL,
    [Has_Trash_around] bit  NULL,
    [Sexual_Abuse] bit  NULL,
    [Relative_In_Prison] bit  NULL,
    [Works_At_Home] bit  NULL,
    [Has_Telephone] bit  NULL,
    [Hours_Spend_Outside] int  NULL,
    [Drug_Addiction] bit  NULL,
    [Has_Water] bit  NULL,
    [Working_Children] bit  NULL,
    [Housing] varchar(16)  NULL,
    [Teenage_Pregnancy] bit  NULL,
    [School_Withdrawal] bit  NULL
);
GO

-- Creating table 'Payments'
CREATE TABLE [dbo].[Payments] (
    [Payment_Id] int IDENTITY(1,1) NOT NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [Date] datetime  NULL,
    [Payment_Amount] float  NULL,
    [Balance_Due] float  NULL,
    [Insurance_Balance] float  NULL,
    [Payment_Document_Info] varchar(200)  NOT NULL,
    [Payment_Extra_Info] varchar(200)  NOT NULL,
    [Invoice_ID] int  NULL
);
GO

-- Creating table 'PediatricPSCs'
CREATE TABLE [dbo].[PediatricPSCs] (
    [PediatricPSC_id] int IDENTITY(1,1) NOT NULL,
    [Evaluation_Date_] datetime  NULL,
    [PSC_Score] int  NULL,
    [Complains_of_aches_and_painsSpends_more_time_alone] varchar(30)  NULL,
    [Tires_easily__has_little_energy] varchar(30)  NULL,
    [Fidgety__unable_to_sit_still] varchar(30)  NULL,
    [Has_trouble_with_teacher] varchar(30)  NULL,
    [Less_interested_in_school] varchar(30)  NULL,
    [Acts_as_if_driven_by_a_motor] varchar(30)  NULL,
    [Daydreams_too_much] varchar(30)  NULL,
    [Distracted_easily] varchar(30)  NULL,
    [Is_afraid_of_new_situations] varchar(30)  NULL,
    [Feels_sad__unhappy] varchar(30)  NULL,
    [Is_irritable__angry] varchar(30)  NULL,
    [Feels_hopeless] varchar(30)  NULL,
    [Has_trouble_concentrating] varchar(30)  NULL,
    [Less_interested_in_friends] varchar(30)  NULL,
    [Fights_with_other_children] varchar(30)  NULL,
    [Absent_from_school] varchar(30)  NULL,
    [School_grades_dropping] varchar(30)  NULL,
    [Is_down_on_him_or_herself] varchar(30)  NULL,
    [Visits_the_doctor_with_doctor_finding_nothing_wrong] varchar(30)  NULL,
    [Has_trouble_sleeping] varchar(30)  NULL,
    [Worries_a_lot] varchar(30)  NULL,
    [Wants_to_be_with_you_more_than_before] varchar(30)  NULL,
    [Feels_he_or_she_is_bad] varchar(30)  NULL,
    [Takes_unnecessary_risks] varchar(30)  NULL,
    [Gets_hurt_frequently] varchar(30)  NULL,
    [Seems_to_be_having_less_fun] varchar(30)  NULL,
    [Acts_younger_than_children_his_or_her_age] varchar(30)  NULL,
    [Does_not_listen_to_rules] varchar(30)  NULL,
    [Does_not_show_feelings] varchar(30)  NULL,
    [Does_not_understand_other_people_s_feelings] varchar(30)  NULL,
    [Teases_others] varchar(30)  NULL,
    [Blames_others_for_his_or_her_troubles] varchar(30)  NULL,
    [Takes_things_that_do_not_belong_to_him_or_her] varchar(30)  NULL,
    [Refuses_to_share] varchar(30)  NULL,
    [Has_emotional_or_behavioral_problems_for_which_needs_help] bit  NULL,
    [Need_to__receive_services_for_these_problems] bit  NULL,
    [What_services] varchar(250)  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [Patient_Id] int  NULL,
    [Doctor_Id] int  NULL
);
GO

-- Creating table 'Perinatal_monitors'
CREATE TABLE [dbo].[Perinatal_monitors] (
    [perinatal_monitor_id] int IDENTITY(1,1) NOT NULL,
    [contractions] int  NULL,
    [bleeding] bit  NULL,
    [dilation] int  NULL,
    [meconium] bit  NULL,
    [fetus_position] nvarchar(16)  NULL,
    [frequency] int  NULL,
    [fundal_height] int  NULL,
    [date] datetime  NULL,
    [systolic] int  NULL,
    [f_frequency] int  NULL,
    [diastolic] int  NULL,
    [Perinatal_id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Perinatals'
CREATE TABLE [dbo].[Perinatals] (
    [Perinatal_id] int IDENTITY(1,1) NOT NULL,
    [create_date] varchar(250)  NULL,
    [prenatal_evaluations] int  NULL,
    [gestational_weeks] int  NULL,
    [abortion] bit  NULL,
    [placenta_retained] bit  NULL,
    [vaginal_tearing] bit  NULL,
    [fetus_presentation] nvarchar(16)  NULL,
    [start_labor_mode] nvarchar(16)  NULL,
    [placenta_incomplete] bit  NULL,
    [gestational_days] int  NULL,
    [episiotomy] bit  NULL,
    [name] nvarchar(128)  NULL,
    [notes] varchar(max)  NULL,
    [admission_date] datetime  NULL,
    [forceps] bit  NULL,
    [dismissed] datetime  NULL,
    [gravida_number] int  NULL,
    [died_at_delivery] bit  NULL,
    [died_being_transferred] bit  NULL,
    [died_at_the_hospital] bit  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Prescriptions'
CREATE TABLE [dbo].[Prescriptions] (
    [Prescription_id] int IDENTITY(1,1) NOT NULL,
    [Common_Name] varchar(100)  NULL,
    [Use_Generic] bit  NULL,
    [Generic_Name] varchar(100)  NULL,
    [Active_Ingredient] varchar(100)  NULL,
    [Dosage] int  NULL,
    [Date_Prescribed] datetime  NULL,
    [Instructions] varchar(200)  NULL,
    [Side_Effects] varchar(max)  NULL,
    [Status] varchar(200)  NULL,
    [Pharmacy] varchar(50)  NULL,
    [Foods_to_avoid] varchar(150)  NULL,
    [Extra_Info] varchar(max)  NULL,
    [Start_Treatment] datetime  NULL,
    [Finish_Treatment] datetime  NULL,
    [Dosage_units] varchar(50)  NULL,
    [Patient_Discontinued_Treatment] bit  NULL,
    [Reason_for_Discontinuation] varchar(200)  NULL,
    [Frequency] int  NULL,
    [Freq_Unit] varchar(max)  NULL,
    [Treatment_Duration] int  NULL,
    [Treatment_Period] varchar(50)  NOT NULL,
    [Review] datetime  NULL,
    [How_Many_Refils] int  NULL,
    [Allow_Substitutions] bit  NULL,
    [Treatment_Is_Active] bit  NULL,
    [Diagno_Id] int  NULL,
    [Patient_Id] int  NULL,
    [Consultation_id] int  NULL,
    [Doctor_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL,
    [Course_Completed] bit  NULL,
    [Adverse_Reaction] varchar(200)  NOT NULL,
    [Adminstration_Times] varchar(128)  NOT NULL,
    [Duration_in_Days] int  NULL,
    [Allow_Refils] bit  NOT NULL,
    [Common_Dosage] int  NOT NULL
);
GO

-- Creating table 'Puerperium_monitors'
CREATE TABLE [dbo].[Puerperium_monitors] (
    [puerperium_monitor_id] int IDENTITY(1,1) NOT NULL,
    [lochia_odor] nvarchar(16)  NULL,
    [lochia_color] nvarchar(16)  NULL,
    [uterus_involution] int  NULL,
    [lochia_amount] nvarchar(16)  NULL,
    [Perinatal_id] int  NULL,
    [puerperium_create_date] datetime  NULL,
    [puerperium_diastolic] int  NULL,
    [puerperium_frequency] int  NULL,
    [puerperium_systolic] int  NULL,
    [puerperium_temperature] float  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Surgeries'
CREATE TABLE [dbo].[Surgeries] (
    [Surgery_id] int IDENTITY(1,1) NOT NULL,
    [Appendectomy] bit  NULL,
    [Aderial_bypass] bit  NULL,
    [Coronas_Ades_Bypass] bit  NULL,
    [Cardiac_valve_repair_or_replace] bit  NULL,
    [Carotid_Endaderectomy] bit  NULL,
    [Cholecystectomy] bit  NULL,
    [Colon_resedion] bit  NULL,
    [Hysterectomy] bit  NULL,
    [Nephrectomy] bit  NULL,
    [Splenedomy] bit  NULL,
    [Pacemaker] bit  NULL,
    [Defibnllator] bit  NULL,
    [Hip_replaoment] bit  NULL,
    [Knee_replacement] bit  NULL,
    [Organ_transplant] bit  NULL,
    [Other_Surgery] bit  NULL,
    [Other_Sugery_Desc] varchar(200)  NULL,
    [Sugeries_Notes] varchar(max)  NULL,
    [Surgery_Name] varchar(100)  NULL,
    [Surgery_Date] datetime  NULL,
    [Surgery_Pathology] varchar(max)  NOT NULL,
    [Surgery_Description] nvarchar(max)  NOT NULL,
    [Doctor_Id] int  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'SystemReviews'
CREATE TABLE [dbo].[SystemReviews] (
    [SystemReview_Id] int IDENTITY(1,1) NOT NULL,
    [Fatigue] bit  NULL,
    [Fever_or_chills] bit  NULL,
    [Appetite_changes] bit  NULL,
    [Conjunctivitis] bit  NULL,
    [New_eye_pain] bit  NULL,
    [Blurred_vision] bit  NULL,
    [Sore_throat] bit  NULL,
    [Nose_bleed] bit  NULL,
    [Dental_caries] bit  NULL,
    [Dental_abscesses] bit  NULL,
    [Swollen_uvula] bit  NULL,
    [Jaw_pain] bit  NULL,
    [Dyspnea] bit  NULL,
    [Cough] bit  NULL,
    [Phlegm] bit  NULL,
    [Hemoptysis] bit  NULL,
    [Wheeze] bit  NULL,
    [Pleuritic_symptoms] bit  NULL,
    [Chess_pain] bit  NULL,
    [Diaphoresis] bit  NULL,
    [Ankle_edema] bit  NULL,
    [Syncope] bit  NULL,
    [Palpitations] bit  NULL,
    [Nausea_or_Vomiting] bit  NULL,
    [Weight_changes] bit  NULL,
    [Constipation_or_Diarrhea] bit  NULL,
    [Abdominal_pain] bit  NULL,
    [Hematuria] bit  NULL,
    [Dysuria] bit  NULL,
    [Urethral_discharge] bit  NULL,
    [Myalgias] bit  NULL,
    [Arthralgias] bit  NULL,
    [Joint_swelling] bit  NULL,
    [Recent_trauma] bit  NULL,
    [Claudication_symptoms] bit  NULL,
    [Masses] bit  NULL,
    [New_skin_lesions] bit  NULL,
    [Sensitivity_to_Sun] bit  NULL,
    [Rash] bit  NULL,
    [Headaches] bit  NULL,
    [Seizures] bit  NULL,
    [Muscle_weakness] bit  NULL,
    [Numbness] bit  NULL,
    [Paresthesias] bit  NULL,
    [Hair_loss] bit  NULL,
    [Polydipsia] bit  NULL,
    [Tremors] bit  NULL,
    [Neck_pain] bit  NULL,
    [Bleeding_gums] bit  NULL,
    [Unusual_bruising] bit  NULL,
    [Swollen_lymph_nodes] bit  NULL,
    [Sinus_problems] bit  NULL,
    [Recurrent_infections] bit  NULL,
    [Nasal_congestion] bit  NULL,
    [Rhinorrhea] bit  NULL,
    [Agitation] bit  NULL,
    [Hallucinations] bit  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'Vaccinations'
CREATE TABLE [dbo].[Vaccinations] (
    [Vacines_Id] int IDENTITY(1,1) NOT NULL,
    [Name_Short] varchar(20)  NULL,
    [Name_Long] varchar(100)  NULL,
    [Description] varchar(400)  NULL,
    [Age] varchar(50)  NULL,
    [Start_Range_Normal] varchar(25)  NULL,
    [End_Range_Normal] varchar(25)  NULL,
    [Start_Range_high_risk] varchar(25)  NULL,
    [End_Range_high_risk] varchar(25)  NULL,
    [Vaccine_for_Pregnant_Women] varchar(25)  NULL,
    [Send_Email] bit  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- Creating table 'WorkFlows'
CREATE TABLE [dbo].[WorkFlows] (
    [WorkFlow_Id] int IDENTITY(1,1) NOT NULL,
    [Abdominal_or_Flank_Pain] bit  NULL,
    [Blood_Vessel_and_Lymphatic] bit  NULL,
    [HIV_or_AIDS] bit  NULL,
    [Protozoal_and_Helminthic] bit  NULL,
    [Gynecologic] bit  NULL,
    [Nervous_System_Disorder] bit  NULL,
    [Fluid_or_Electrolyte_Disorders] bit  NULL,
    [Hemostasis_Thrombosis] bit  NULL,
    [Psychiatric_Disorder] bit  NULL,
    [Endocrine_Disorders] bit  NULL,
    [Lipid_Disorders] bit  NULL,
    [Nutritional_Disorders] bit  NULL,
    [Infectious_Diseases_and_Antimicrobial_Therapy] bit  NULL,
    [Resistance_to_antibiotic] bit  NULL,
    [Viral_Diseases] bit  NULL,
    [Spirochetal] bit  NULL,
    [Mycotic_Infectious] bit  NULL,
    [Bleeding_Wound] bit  NULL,
    [Infected_Wound] bit  NULL,
    [Disorders_Due_to_Physical_Agents] bit  NULL,
    [Poisoning] bit  NULL,
    [Cancer] bit  NULL,
    [Metabolic_Disease] bit  NULL,
    [Bone_Fracture] bit  NULL,
    [Exposed_Fracture] bit  NULL,
    [Bone_Decay] bit  NULL,
    [Rheumatic] bit  NULL,
    [Aging_Problems] bit  NULL,
    [Bacterial_or_Chlamydial_Infections] bit  NULL,
    [Allergic_Disease] bit  NULL,
    [Anxiety_or_Depression] bit  NULL,
    [Asthma_or_COPD_or_Wheezing] bit  NULL,
    [Back_or_Neck_Injury_or_Pain] bit  NULL,
    [Breast_Problems] bit  NULL,
    [Cardiovascular] bit  NULL,
    [Chest_Pain] bit  NULL,
    [Congestive_Heart_Failure] bit  NULL,
    [Coronary_Artery_Disease] bit  NULL,
    [Diabetes_Mellitus_or_Hypoglycemia] bit  NULL,
    [Ear_Nose_and_Throat] bit  NULL,
    [Epistaxis_or_Nasal_Foreign_Body] bit  NULL,
    [Extremity_Injury_or_Pain] bit  NULL,
    [Eye_and_Lids] bit  NULL,
    [Gastrointestinal_Disorders] bit  NULL,
    [Urologic] bit  NULL,
    [Liver_Biliary_Track_or_Pancreas] bit  NULL,
    [Headache] bit  NULL,
    [Hematologic_Disorder] bit  NULL,
    [Hepatitis_or_Liver_Failure] bit  NULL,
    [Hyperlipidemia] bit  NULL,
    [Hypertension] bit  NULL,
    [Musculoskeletal] bit  NULL,
    [Nausea_Vomiting_Diarrhea] bit  NULL,
    [Neurology] bit  NULL,
    [Obesity] bit  NULL,
    [Osteoporosis] bit  NULL,
    [Pediatric_Illness] bit  NULL,
    [Pulmonary] bit  NULL,
    [Seizure] bit  NULL,
    [Dermatologic] bit  NULL,
    [Sleep_Apnea] bit  NULL,
    [Sore_Throat] bit  NULL,
    [Dental_Pain] bit  NULL,
    [Thyroid_Disease] bit  NULL,
    [Upper_Respiratory_Symptoms] bit  NULL,
    [Vascular_Occlusive_Disease] bit  NULL,
    [General_Physical_Exam_Adult] bit  NULL,
    [General_Physical_Exam_Child] bit  NULL,
    [Other] bit  NULL,
    [Other_value] varchar(200)  NULL,
    [Patient_Id] int  NULL,
    [create_uid] varchar(250)  NULL,
    [create_date] varchar(250)  NULL,
    [write_uid] varchar(250)  NULL,
    [write_date] varchar(250)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Apointment_id] in table 'Appointments'
ALTER TABLE [dbo].[Appointments]
ADD CONSTRAINT [PK_Appointments]
    PRIMARY KEY CLUSTERED ([Apointment_id] ASC);
GO

-- Creating primary key on [BodyRegion_id] in table 'BodyRegions'
ALTER TABLE [dbo].[BodyRegions]
ADD CONSTRAINT [PK_BodyRegions]
    PRIMARY KEY CLUSTERED ([BodyRegion_id] ASC);
GO

-- Creating primary key on [Charge_Id] in table 'Charges'
ALTER TABLE [dbo].[Charges]
ADD CONSTRAINT [PK_Charges]
    PRIMARY KEY CLUSTERED ([Charge_Id] ASC);
GO

-- Creating primary key on [ClinicChart_Id] in table 'ClinicCharts'
ALTER TABLE [dbo].[ClinicCharts]
ADD CONSTRAINT [PK_ClinicCharts]
    PRIMARY KEY CLUSTERED ([ClinicChart_Id] ASC);
GO

-- Creating primary key on [Consult_Payment_id] in table 'Consult_Payments'
ALTER TABLE [dbo].[Consult_Payments]
ADD CONSTRAINT [PK_Consult_Payments]
    PRIMARY KEY CLUSTERED ([Consult_Payment_id] ASC);
GO

-- Creating primary key on [Consultation_id] in table 'Consultations'
ALTER TABLE [dbo].[Consultations]
ADD CONSTRAINT [PK_Consultations]
    PRIMARY KEY CLUSTERED ([Consultation_id] ASC);
GO

-- Creating primary key on [Diagno_Id] in table 'Diagnos'
ALTER TABLE [dbo].[Diagnos]
ADD CONSTRAINT [PK_Diagnos]
    PRIMARY KEY CLUSTERED ([Diagno_Id] ASC);
GO

-- Creating primary key on [Doctor_Id] in table 'Doctors'
ALTER TABLE [dbo].[Doctors]
ADD CONSTRAINT [PK_Doctors]
    PRIMARY KEY CLUSTERED ([Doctor_Id] ASC);
GO

-- Creating primary key on [Evaluation_CV_id] in table 'Evaluation_Cardios'
ALTER TABLE [dbo].[Evaluation_Cardios]
ADD CONSTRAINT [PK_Evaluation_Cardios]
    PRIMARY KEY CLUSTERED ([Evaluation_CV_id] ASC);
GO

-- Creating primary key on [Evaluation_Cons_id] in table 'Evaluation_Constitutionals'
ALTER TABLE [dbo].[Evaluation_Constitutionals]
ADD CONSTRAINT [PK_Evaluation_Constitutionals]
    PRIMARY KEY CLUSTERED ([Evaluation_Cons_id] ASC);
GO

-- Creating primary key on [Evaluation_Ent_id] in table 'Evaluation_Ents'
ALTER TABLE [dbo].[Evaluation_Ents]
ADD CONSTRAINT [PK_Evaluation_Ents]
    PRIMARY KEY CLUSTERED ([Evaluation_Ent_id] ASC);
GO

-- Creating primary key on [Evaluation_Extrem_id] in table 'Evaluation_Extrems'
ALTER TABLE [dbo].[Evaluation_Extrems]
ADD CONSTRAINT [PK_Evaluation_Extrems]
    PRIMARY KEY CLUSTERED ([Evaluation_Extrem_id] ASC);
GO

-- Creating primary key on [Evaluation_Gastro_id] in table 'Evaluation_Gastros'
ALTER TABLE [dbo].[Evaluation_Gastros]
ADD CONSTRAINT [PK_Evaluation_Gastros]
    PRIMARY KEY CLUSTERED ([Evaluation_Gastro_id] ASC);
GO

-- Creating primary key on [Evaluation_Lymph_id] in table 'Evaluation_Lymphs'
ALTER TABLE [dbo].[Evaluation_Lymphs]
ADD CONSTRAINT [PK_Evaluation_Lymphs]
    PRIMARY KEY CLUSTERED ([Evaluation_Lymph_id] ASC);
GO

-- Creating primary key on [Evaluation_Musc_id] in table 'Evaluation_Muscs'
ALTER TABLE [dbo].[Evaluation_Muscs]
ADD CONSTRAINT [PK_Evaluation_Muscs]
    PRIMARY KEY CLUSTERED ([Evaluation_Musc_id] ASC);
GO

-- Creating primary key on [Evaluation_Neck_id] in table 'Evaluation_Necks'
ALTER TABLE [dbo].[Evaluation_Necks]
ADD CONSTRAINT [PK_Evaluation_Necks]
    PRIMARY KEY CLUSTERED ([Evaluation_Neck_id] ASC);
GO

-- Creating primary key on [Evaluation_Neuro_id] in table 'Evaluation_Neuros'
ALTER TABLE [dbo].[Evaluation_Neuros]
ADD CONSTRAINT [PK_Evaluation_Neuros]
    PRIMARY KEY CLUSTERED ([Evaluation_Neuro_id] ASC);
GO

-- Creating primary key on [Evaluation_Resp_id] in table 'Evaluation_Respis'
ALTER TABLE [dbo].[Evaluation_Respis]
ADD CONSTRAINT [PK_Evaluation_Respis]
    PRIMARY KEY CLUSTERED ([Evaluation_Resp_id] ASC);
GO

-- Creating primary key on [Evaluation_Skin_id] in table 'Evaluation_Skins'
ALTER TABLE [dbo].[Evaluation_Skins]
ADD CONSTRAINT [PK_Evaluation_Skins]
    PRIMARY KEY CLUSTERED ([Evaluation_Skin_id] ASC);
GO

-- Creating primary key on [ExamCategory_id] in table 'ExamCategories'
ALTER TABLE [dbo].[ExamCategories]
ADD CONSTRAINT [PK_ExamCategories]
    PRIMARY KEY CLUSTERED ([ExamCategory_id] ASC);
GO

-- Creating primary key on [Exam_id] in table 'Exams'
ALTER TABLE [dbo].[Exams]
ADD CONSTRAINT [PK_Exams]
    PRIMARY KEY CLUSTERED ([Exam_id] ASC);
GO

-- Creating primary key on [ExamType_id] in table 'ExamTypes'
ALTER TABLE [dbo].[ExamTypes]
ADD CONSTRAINT [PK_ExamTypes]
    PRIMARY KEY CLUSTERED ([ExamType_id] ASC);
GO

-- Creating primary key on [Hereditary_Illnesses_Id] in table 'Hereditary_Illnes'
ALTER TABLE [dbo].[Hereditary_Illnes]
ADD CONSTRAINT [PK_Hereditary_Illnes]
    PRIMARY KEY CLUSTERED ([Hereditary_Illnesses_Id] ASC);
GO

-- Creating primary key on [Hospital_bed_Id] in table 'Hospital_bed'
ALTER TABLE [dbo].[Hospital_bed]
ADD CONSTRAINT [PK_Hospital_bed]
    PRIMARY KEY CLUSTERED ([Hospital_bed_Id] ASC);
GO

-- Creating primary key on [Hospital_Building_Id] in table 'Hospital_buildings'
ALTER TABLE [dbo].[Hospital_buildings]
ADD CONSTRAINT [PK_Hospital_buildings]
    PRIMARY KEY CLUSTERED ([Hospital_Building_Id] ASC);
GO

-- Creating primary key on [Hospital_unit_Id] in table 'Hospital_units'
ALTER TABLE [dbo].[Hospital_units]
ADD CONSTRAINT [PK_Hospital_units]
    PRIMARY KEY CLUSTERED ([Hospital_unit_Id] ASC);
GO

-- Creating primary key on [Hospital_ward_Id] in table 'Hospital_wards'
ALTER TABLE [dbo].[Hospital_wards]
ADD CONSTRAINT [PK_Hospital_wards]
    PRIMARY KEY CLUSTERED ([Hospital_ward_Id] ASC);
GO

-- Creating primary key on [Inpatient_reg_Id] in table 'Inpatient_regs'
ALTER TABLE [dbo].[Inpatient_regs]
ADD CONSTRAINT [PK_Inpatient_regs]
    PRIMARY KEY CLUSTERED ([Inpatient_reg_Id] ASC);
GO

-- Creating primary key on [Insurance_Payment_id] in table 'Insurance_Payments'
ALTER TABLE [dbo].[Insurance_Payments]
ADD CONSTRAINT [PK_Insurance_Payments]
    PRIMARY KEY CLUSTERED ([Insurance_Payment_id] ASC);
GO

-- Creating primary key on [Insurance_ID] in table 'Insurances'
ALTER TABLE [dbo].[Insurances]
ADD CONSTRAINT [PK_Insurances]
    PRIMARY KEY CLUSTERED ([Insurance_ID] ASC);
GO

-- Creating primary key on [Invoice_ID] in table 'Invoices'
ALTER TABLE [dbo].[Invoices]
ADD CONSTRAINT [PK_Invoices]
    PRIMARY KEY CLUSTERED ([Invoice_ID] ASC);
GO

-- Creating primary key on [Lab_id] in table 'Labs'
ALTER TABLE [dbo].[Labs]
ADD CONSTRAINT [PK_Labs]
    PRIMARY KEY CLUSTERED ([Lab_id] ASC);
GO

-- Creating primary key on [Medical_History_Id] in table 'Medical_Histos'
ALTER TABLE [dbo].[Medical_Histos]
ADD CONSTRAINT [PK_Medical_Histos]
    PRIMARY KEY CLUSTERED ([Medical_History_Id] ASC);
GO

-- Creating primary key on [Medicament_id] in table 'Medicaments'
ALTER TABLE [dbo].[Medicaments]
ADD CONSTRAINT [PK_Medicaments]
    PRIMARY KEY CLUSTERED ([Medicament_id] ASC);
GO

-- Creating primary key on [MedicationReaction_Id] in table 'MedicationReactions'
ALTER TABLE [dbo].[MedicationReactions]
ADD CONSTRAINT [PK_MedicationReactions]
    PRIMARY KEY CLUSTERED ([MedicationReaction_Id] ASC);
GO

-- Creating primary key on [Newborn_id] in table 'Newborns'
ALTER TABLE [dbo].[Newborns]
ADD CONSTRAINT [PK_Newborns]
    PRIMARY KEY CLUSTERED ([Newborn_id] ASC);
GO

-- Creating primary key on [Pathology_id] in table 'Pathologies'
ALTER TABLE [dbo].[Pathologies]
ADD CONSTRAINT [PK_Pathologies]
    PRIMARY KEY CLUSTERED ([Pathology_id] ASC);
GO

-- Creating primary key on [Pat_category_Id] in table 'Pathology_Categories'
ALTER TABLE [dbo].[Pathology_Categories]
ADD CONSTRAINT [PK_Pathology_Categories]
    PRIMARY KEY CLUSTERED ([Pat_category_Id] ASC);
GO

-- Creating primary key on [PatientAllergy_id] in table 'PatientAllergies'
ALTER TABLE [dbo].[PatientAllergies]
ADD CONSTRAINT [PK_PatientAllergies]
    PRIMARY KEY CLUSTERED ([PatientAllergy_id] ASC);
GO

-- Creating primary key on [Patient_Id] in table 'Patients'
ALTER TABLE [dbo].[Patients]
ADD CONSTRAINT [PK_Patients]
    PRIMARY KEY CLUSTERED ([Patient_Id] ASC);
GO

-- Creating primary key on [Payment_Id] in table 'Payments'
ALTER TABLE [dbo].[Payments]
ADD CONSTRAINT [PK_Payments]
    PRIMARY KEY CLUSTERED ([Payment_Id] ASC);
GO

-- Creating primary key on [PediatricPSC_id] in table 'PediatricPSCs'
ALTER TABLE [dbo].[PediatricPSCs]
ADD CONSTRAINT [PK_PediatricPSCs]
    PRIMARY KEY CLUSTERED ([PediatricPSC_id] ASC);
GO

-- Creating primary key on [perinatal_monitor_id] in table 'Perinatal_monitors'
ALTER TABLE [dbo].[Perinatal_monitors]
ADD CONSTRAINT [PK_Perinatal_monitors]
    PRIMARY KEY CLUSTERED ([perinatal_monitor_id] ASC);
GO

-- Creating primary key on [Perinatal_id] in table 'Perinatals'
ALTER TABLE [dbo].[Perinatals]
ADD CONSTRAINT [PK_Perinatals]
    PRIMARY KEY CLUSTERED ([Perinatal_id] ASC);
GO

-- Creating primary key on [Prescription_id] in table 'Prescriptions'
ALTER TABLE [dbo].[Prescriptions]
ADD CONSTRAINT [PK_Prescriptions]
    PRIMARY KEY CLUSTERED ([Prescription_id] ASC);
GO

-- Creating primary key on [puerperium_monitor_id] in table 'Puerperium_monitors'
ALTER TABLE [dbo].[Puerperium_monitors]
ADD CONSTRAINT [PK_Puerperium_monitors]
    PRIMARY KEY CLUSTERED ([puerperium_monitor_id] ASC);
GO

-- Creating primary key on [Surgery_id] in table 'Surgeries'
ALTER TABLE [dbo].[Surgeries]
ADD CONSTRAINT [PK_Surgeries]
    PRIMARY KEY CLUSTERED ([Surgery_id] ASC);
GO

-- Creating primary key on [SystemReview_Id] in table 'SystemReviews'
ALTER TABLE [dbo].[SystemReviews]
ADD CONSTRAINT [PK_SystemReviews]
    PRIMARY KEY CLUSTERED ([SystemReview_Id] ASC);
GO

-- Creating primary key on [Vacines_Id] in table 'Vaccinations'
ALTER TABLE [dbo].[Vaccinations]
ADD CONSTRAINT [PK_Vaccinations]
    PRIMARY KEY CLUSTERED ([Vacines_Id] ASC);
GO

-- Creating primary key on [WorkFlow_Id] in table 'WorkFlows'
ALTER TABLE [dbo].[WorkFlows]
ADD CONSTRAINT [PK_WorkFlows]
    PRIMARY KEY CLUSTERED ([WorkFlow_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Doctor_Id] in table 'Appointments'
ALTER TABLE [dbo].[Appointments]
ADD CONSTRAINT [FK_AppointmentDoctor]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AppointmentDoctor'
CREATE INDEX [IX_FK_AppointmentDoctor]
ON [dbo].[Appointments]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Appointments'
ALTER TABLE [dbo].[Appointments]
ADD CONSTRAINT [FK_Appointmentmed_Patient]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Appointmentmed_Patient'
CREATE INDEX [IX_FK_Appointmentmed_Patient]
ON [dbo].[Appointments]
    ([Patient_Id]);
GO

-- Creating foreign key on [Exam_id] in table 'BodyRegions'
ALTER TABLE [dbo].[BodyRegions]
ADD CONSTRAINT [FK_med_Examsmed_BodyRegion]
    FOREIGN KEY ([Exam_id])
    REFERENCES [dbo].[Exams]
        ([Exam_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Examsmed_BodyRegion'
CREATE INDEX [IX_FK_med_Examsmed_BodyRegion]
ON [dbo].[BodyRegions]
    ([Exam_id]);
GO

-- Creating foreign key on [Invoice_ID] in table 'Charges'
ALTER TABLE [dbo].[Charges]
ADD CONSTRAINT [FK_InvoiceCharge]
    FOREIGN KEY ([Invoice_ID])
    REFERENCES [dbo].[Invoices]
        ([Invoice_ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoiceCharge'
CREATE INDEX [IX_FK_InvoiceCharge]
ON [dbo].[Charges]
    ([Invoice_ID]);
GO

-- Creating foreign key on [Patient_Id] in table 'ClinicCharts'
ALTER TABLE [dbo].[ClinicCharts]
ADD CONSTRAINT [FK_ClinicChartPatients]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ClinicChartPatients'
CREATE INDEX [IX_FK_ClinicChartPatients]
ON [dbo].[ClinicCharts]
    ([Patient_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Cardios'
ALTER TABLE [dbo].[Evaluation_Cardios]
ADD CONSTRAINT [FK_Evaluation_CardioClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_CardioClinicChart'
CREATE INDEX [IX_FK_Evaluation_CardioClinicChart]
ON [dbo].[Evaluation_Cardios]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Constitutionals'
ALTER TABLE [dbo].[Evaluation_Constitutionals]
ADD CONSTRAINT [FK_Evaluation_ConstitutionalClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_ConstitutionalClinicChart'
CREATE INDEX [IX_FK_Evaluation_ConstitutionalClinicChart]
ON [dbo].[Evaluation_Constitutionals]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Ents'
ALTER TABLE [dbo].[Evaluation_Ents]
ADD CONSTRAINT [FK_Evaluation_EntClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_EntClinicChart'
CREATE INDEX [IX_FK_Evaluation_EntClinicChart]
ON [dbo].[Evaluation_Ents]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Extrems'
ALTER TABLE [dbo].[Evaluation_Extrems]
ADD CONSTRAINT [FK_Evaluation_ExtremClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_ExtremClinicChart'
CREATE INDEX [IX_FK_Evaluation_ExtremClinicChart]
ON [dbo].[Evaluation_Extrems]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Gastros'
ALTER TABLE [dbo].[Evaluation_Gastros]
ADD CONSTRAINT [FK_Evaluation_GastroClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_GastroClinicChart'
CREATE INDEX [IX_FK_Evaluation_GastroClinicChart]
ON [dbo].[Evaluation_Gastros]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Lymphs'
ALTER TABLE [dbo].[Evaluation_Lymphs]
ADD CONSTRAINT [FK_Evaluation_LymphClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_LymphClinicChart'
CREATE INDEX [IX_FK_Evaluation_LymphClinicChart]
ON [dbo].[Evaluation_Lymphs]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Muscs'
ALTER TABLE [dbo].[Evaluation_Muscs]
ADD CONSTRAINT [FK_Evaluation_MuscClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_MuscClinicChart'
CREATE INDEX [IX_FK_Evaluation_MuscClinicChart]
ON [dbo].[Evaluation_Muscs]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Necks'
ALTER TABLE [dbo].[Evaluation_Necks]
ADD CONSTRAINT [FK_Evaluation_NeckClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_NeckClinicChart'
CREATE INDEX [IX_FK_Evaluation_NeckClinicChart]
ON [dbo].[Evaluation_Necks]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Neuros'
ALTER TABLE [dbo].[Evaluation_Neuros]
ADD CONSTRAINT [FK_Evaluation_NeuroClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_NeuroClinicChart'
CREATE INDEX [IX_FK_Evaluation_NeuroClinicChart]
ON [dbo].[Evaluation_Neuros]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Respis'
ALTER TABLE [dbo].[Evaluation_Respis]
ADD CONSTRAINT [FK_Evaluation_RespClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_RespClinicChart'
CREATE INDEX [IX_FK_Evaluation_RespClinicChart]
ON [dbo].[Evaluation_Respis]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Evaluation_Skins'
ALTER TABLE [dbo].[Evaluation_Skins]
ADD CONSTRAINT [FK_Evaluation_SkinClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Evaluation_SkinClinicChart'
CREATE INDEX [IX_FK_Evaluation_SkinClinicChart]
ON [dbo].[Evaluation_Skins]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [ClinicChart_Id] in table 'Hereditary_Illnes'
ALTER TABLE [dbo].[Hereditary_Illnes]
ADD CONSTRAINT [FK_Hereditary_IllnessesClinicChart]
    FOREIGN KEY ([ClinicChart_Id])
    REFERENCES [dbo].[ClinicCharts]
        ([ClinicChart_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hereditary_IllnessesClinicChart'
CREATE INDEX [IX_FK_Hereditary_IllnessesClinicChart]
ON [dbo].[Hereditary_Illnes]
    ([ClinicChart_Id]);
GO

-- Creating foreign key on [Consultation_id] in table 'Consult_Payments'
ALTER TABLE [dbo].[Consult_Payments]
ADD CONSTRAINT [FK_med_Consultationsmed_Consult_fees]
    FOREIGN KEY ([Consultation_id])
    REFERENCES [dbo].[Consultations]
        ([Consultation_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Consultationsmed_Consult_fees'
CREATE INDEX [IX_FK_med_Consultationsmed_Consult_fees]
ON [dbo].[Consult_Payments]
    ([Consultation_id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Consult_Payments'
ALTER TABLE [dbo].[Consult_Payments]
ADD CONSTRAINT [FK_med_Patientmed_Consult_fees]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Consult_fees'
CREATE INDEX [IX_FK_med_Patientmed_Consult_fees]
ON [dbo].[Consult_Payments]
    ([Patient_Id]);
GO

-- Creating foreign key on [Consultation_id] in table 'Diagnos'
ALTER TABLE [dbo].[Diagnos]
ADD CONSTRAINT [FK_med_Consultationsmed_Diagnosis]
    FOREIGN KEY ([Consultation_id])
    REFERENCES [dbo].[Consultations]
        ([Consultation_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Consultationsmed_Diagnosis'
CREATE INDEX [IX_FK_med_Consultationsmed_Diagnosis]
ON [dbo].[Diagnos]
    ([Consultation_id]);
GO

-- Creating foreign key on [Consultation_id] in table 'Exams'
ALTER TABLE [dbo].[Exams]
ADD CONSTRAINT [FK_med_Consultationsmed_Exams]
    FOREIGN KEY ([Consultation_id])
    REFERENCES [dbo].[Consultations]
        ([Consultation_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Consultationsmed_Exams'
CREATE INDEX [IX_FK_med_Consultationsmed_Exams]
ON [dbo].[Exams]
    ([Consultation_id]);
GO

-- Creating foreign key on [Consultation_id] in table 'Insurances'
ALTER TABLE [dbo].[Insurances]
ADD CONSTRAINT [FK_med_Consultationsmed_Insurance]
    FOREIGN KEY ([Consultation_id])
    REFERENCES [dbo].[Consultations]
        ([Consultation_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Consultationsmed_Insurance'
CREATE INDEX [IX_FK_med_Consultationsmed_Insurance]
ON [dbo].[Insurances]
    ([Consultation_id]);
GO

-- Creating foreign key on [Consultation_id] in table 'Pathologies'
ALTER TABLE [dbo].[Pathologies]
ADD CONSTRAINT [FK_med_Consultationsmed_pathology]
    FOREIGN KEY ([Consultation_id])
    REFERENCES [dbo].[Consultations]
        ([Consultation_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Consultationsmed_pathology'
CREATE INDEX [IX_FK_med_Consultationsmed_pathology]
ON [dbo].[Pathologies]
    ([Consultation_id]);
GO

-- Creating foreign key on [Consultation_id] in table 'Prescriptions'
ALTER TABLE [dbo].[Prescriptions]
ADD CONSTRAINT [FK_med_Consultationsmed_Prescriptions]
    FOREIGN KEY ([Consultation_id])
    REFERENCES [dbo].[Consultations]
        ([Consultation_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Consultationsmed_Prescriptions'
CREATE INDEX [IX_FK_med_Consultationsmed_Prescriptions]
ON [dbo].[Prescriptions]
    ([Consultation_id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Consultations'
ALTER TABLE [dbo].[Consultations]
ADD CONSTRAINT [FK_med_Doctormed_Consultations]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Doctormed_Consultations'
CREATE INDEX [IX_FK_med_Doctormed_Consultations]
ON [dbo].[Consultations]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Consultations'
ALTER TABLE [dbo].[Consultations]
ADD CONSTRAINT [FK_med_Patientmed_Consultations]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Consultations'
CREATE INDEX [IX_FK_med_Patientmed_Consultations]
ON [dbo].[Consultations]
    ([Patient_Id]);
GO

-- Creating foreign key on [Diagno_Id] in table 'Labs'
ALTER TABLE [dbo].[Labs]
ADD CONSTRAINT [FK_LabDiagnosis]
    FOREIGN KEY ([Diagno_Id])
    REFERENCES [dbo].[Diagnos]
        ([Diagno_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LabDiagnosis'
CREATE INDEX [IX_FK_LabDiagnosis]
ON [dbo].[Labs]
    ([Diagno_Id]);
GO

-- Creating foreign key on [Diagno_Id] in table 'Exams'
ALTER TABLE [dbo].[Exams]
ADD CONSTRAINT [FK_med_Diagnosismed_Exams]
    FOREIGN KEY ([Diagno_Id])
    REFERENCES [dbo].[Diagnos]
        ([Diagno_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Diagnosismed_Exams'
CREATE INDEX [IX_FK_med_Diagnosismed_Exams]
ON [dbo].[Exams]
    ([Diagno_Id]);
GO

-- Creating foreign key on [Diagno_Id] in table 'Prescriptions'
ALTER TABLE [dbo].[Prescriptions]
ADD CONSTRAINT [FK_med_Diagnosismed_Prescriptions]
    FOREIGN KEY ([Diagno_Id])
    REFERENCES [dbo].[Diagnos]
        ([Diagno_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Diagnosismed_Prescriptions'
CREATE INDEX [IX_FK_med_Diagnosismed_Prescriptions]
ON [dbo].[Prescriptions]
    ([Diagno_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Diagnos'
ALTER TABLE [dbo].[Diagnos]
ADD CONSTRAINT [FK_med_Doctormed_Diagnosis]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Doctormed_Diagnosis'
CREATE INDEX [IX_FK_med_Doctormed_Diagnosis]
ON [dbo].[Diagnos]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Diagnos'
ALTER TABLE [dbo].[Diagnos]
ADD CONSTRAINT [FK_med_Patientmed_Diagnosis]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Diagnosis'
CREATE INDEX [IX_FK_med_Patientmed_Diagnosis]
ON [dbo].[Diagnos]
    ([Patient_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'PediatricPSCs'
ALTER TABLE [dbo].[PediatricPSCs]
ADD CONSTRAINT [FK_DoctorPediatricPSC]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DoctorPediatricPSC'
CREATE INDEX [IX_FK_DoctorPediatricPSC]
ON [dbo].[PediatricPSCs]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Labs'
ALTER TABLE [dbo].[Labs]
ADD CONSTRAINT [FK_LabDoctor]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LabDoctor'
CREATE INDEX [IX_FK_LabDoctor]
ON [dbo].[Labs]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Exams'
ALTER TABLE [dbo].[Exams]
ADD CONSTRAINT [FK_med_Doctormed_Exams]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Doctormed_Exams'
CREATE INDEX [IX_FK_med_Doctormed_Exams]
ON [dbo].[Exams]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Patients'
ALTER TABLE [dbo].[Patients]
ADD CONSTRAINT [FK_med_Doctormed_Patient]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Doctormed_Patient'
CREATE INDEX [IX_FK_med_Doctormed_Patient]
ON [dbo].[Patients]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Surgeries'
ALTER TABLE [dbo].[Surgeries]
ADD CONSTRAINT [FK_med_Doctormed_Surgeries]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Doctormed_Surgeries'
CREATE INDEX [IX_FK_med_Doctormed_Surgeries]
ON [dbo].[Surgeries]
    ([Doctor_Id]);
GO

-- Creating foreign key on [Doctor_Id] in table 'Prescriptions'
ALTER TABLE [dbo].[Prescriptions]
ADD CONSTRAINT [FK_med_Prescriptionsmed_Doctor]
    FOREIGN KEY ([Doctor_Id])
    REFERENCES [dbo].[Doctors]
        ([Doctor_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Prescriptionsmed_Doctor'
CREATE INDEX [IX_FK_med_Prescriptionsmed_Doctor]
ON [dbo].[Prescriptions]
    ([Doctor_Id]);
GO

-- Creating foreign key on [ExamType_id] in table 'ExamCategories'
ALTER TABLE [dbo].[ExamCategories]
ADD CONSTRAINT [FK_med_ExamTypemed_ExamCategory]
    FOREIGN KEY ([ExamType_id])
    REFERENCES [dbo].[ExamTypes]
        ([ExamType_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_ExamTypemed_ExamCategory'
CREATE INDEX [IX_FK_med_ExamTypemed_ExamCategory]
ON [dbo].[ExamCategories]
    ([ExamType_id]);
GO

-- Creating foreign key on [Exam_id] in table 'Labs'
ALTER TABLE [dbo].[Labs]
ADD CONSTRAINT [FK_LabExams]
    FOREIGN KEY ([Exam_id])
    REFERENCES [dbo].[Exams]
        ([Exam_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LabExams'
CREATE INDEX [IX_FK_LabExams]
ON [dbo].[Labs]
    ([Exam_id]);
GO

-- Creating foreign key on [Exam_id] in table 'ExamTypes'
ALTER TABLE [dbo].[ExamTypes]
ADD CONSTRAINT [FK_med_Examsmed_ExamType]
    FOREIGN KEY ([Exam_id])
    REFERENCES [dbo].[Exams]
        ([Exam_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Examsmed_ExamType'
CREATE INDEX [IX_FK_med_Examsmed_ExamType]
ON [dbo].[ExamTypes]
    ([Exam_id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Exams'
ALTER TABLE [dbo].[Exams]
ADD CONSTRAINT [FK_med_Patientmed_Exams]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Exams'
CREATE INDEX [IX_FK_med_Patientmed_Exams]
ON [dbo].[Exams]
    ([Patient_Id]);
GO

-- Creating foreign key on [Hospital_bed_Id] in table 'Inpatient_regs'
ALTER TABLE [dbo].[Inpatient_regs]
ADD CONSTRAINT [FK_Hospital_bedInpatient_registrations]
    FOREIGN KEY ([Hospital_bed_Id])
    REFERENCES [dbo].[Hospital_bed]
        ([Hospital_bed_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hospital_bedInpatient_registrations'
CREATE INDEX [IX_FK_Hospital_bedInpatient_registrations]
ON [dbo].[Inpatient_regs]
    ([Hospital_bed_Id]);
GO

-- Creating foreign key on [Hospital_ward_Id] in table 'Hospital_bed'
ALTER TABLE [dbo].[Hospital_bed]
ADD CONSTRAINT [FK_Hospital_wardHospital_bed]
    FOREIGN KEY ([Hospital_ward_Id])
    REFERENCES [dbo].[Hospital_wards]
        ([Hospital_ward_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hospital_wardHospital_bed'
CREATE INDEX [IX_FK_Hospital_wardHospital_bed]
ON [dbo].[Hospital_bed]
    ([Hospital_ward_Id]);
GO

-- Creating foreign key on [Hospital_Building_Id] in table 'Hospital_wards'
ALTER TABLE [dbo].[Hospital_wards]
ADD CONSTRAINT [FK_Hospital_buildingHospital_ward]
    FOREIGN KEY ([Hospital_Building_Id])
    REFERENCES [dbo].[Hospital_buildings]
        ([Hospital_Building_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hospital_buildingHospital_ward'
CREATE INDEX [IX_FK_Hospital_buildingHospital_ward]
ON [dbo].[Hospital_wards]
    ([Hospital_Building_Id]);
GO

-- Creating foreign key on [Hospital_unit_Id] in table 'Hospital_wards'
ALTER TABLE [dbo].[Hospital_wards]
ADD CONSTRAINT [FK_Hospital_unitHospital_ward]
    FOREIGN KEY ([Hospital_unit_Id])
    REFERENCES [dbo].[Hospital_units]
        ([Hospital_unit_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Hospital_unitHospital_ward'
CREATE INDEX [IX_FK_Hospital_unitHospital_ward]
ON [dbo].[Hospital_wards]
    ([Hospital_unit_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Inpatient_regs'
ALTER TABLE [dbo].[Inpatient_regs]
ADD CONSTRAINT [FK_Inpatient_registrationsPatients]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Inpatient_registrationsPatients'
CREATE INDEX [IX_FK_Inpatient_registrationsPatients]
ON [dbo].[Inpatient_regs]
    ([Patient_Id]);
GO

-- Creating foreign key on [Insurance_ID] in table 'Insurance_Payments'
ALTER TABLE [dbo].[Insurance_Payments]
ADD CONSTRAINT [FK_med_Insurancemed_Insurance_Fees]
    FOREIGN KEY ([Insurance_ID])
    REFERENCES [dbo].[Insurances]
        ([Insurance_ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Insurancemed_Insurance_Fees'
CREATE INDEX [IX_FK_med_Insurancemed_Insurance_Fees]
ON [dbo].[Insurance_Payments]
    ([Insurance_ID]);
GO

-- Creating foreign key on [Insurance_ID] in table 'Invoices'
ALTER TABLE [dbo].[Invoices]
ADD CONSTRAINT [FK_InsuranceInvoice]
    FOREIGN KEY ([Insurance_ID])
    REFERENCES [dbo].[Insurances]
        ([Insurance_ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InsuranceInvoice'
CREATE INDEX [IX_FK_InsuranceInvoice]
ON [dbo].[Invoices]
    ([Insurance_ID]);
GO

-- Creating foreign key on [Patient_Id] in table 'Invoices'
ALTER TABLE [dbo].[Invoices]
ADD CONSTRAINT [FK_InvoicePatients]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoicePatients'
CREATE INDEX [IX_FK_InvoicePatients]
ON [dbo].[Invoices]
    ([Patient_Id]);
GO

-- Creating foreign key on [Invoice_ID] in table 'Payments'
ALTER TABLE [dbo].[Payments]
ADD CONSTRAINT [FK_InvoicePayment]
    FOREIGN KEY ([Invoice_ID])
    REFERENCES [dbo].[Invoices]
        ([Invoice_ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoicePayment'
CREATE INDEX [IX_FK_InvoicePayment]
ON [dbo].[Payments]
    ([Invoice_ID]);
GO

-- Creating foreign key on [Patient_Id] in table 'Labs'
ALTER TABLE [dbo].[Labs]
ADD CONSTRAINT [FK_LabPatient]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LabPatient'
CREATE INDEX [IX_FK_LabPatient]
ON [dbo].[Labs]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Medical_Histos'
ALTER TABLE [dbo].[Medical_Histos]
ADD CONSTRAINT [FK_med_Patientmed_Medical_History]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Medical_History'
CREATE INDEX [IX_FK_med_Patientmed_Medical_History]
ON [dbo].[Medical_Histos]
    ([Patient_Id]);
GO

-- Creating foreign key on [Prescription_id] in table 'Medicaments'
ALTER TABLE [dbo].[Medicaments]
ADD CONSTRAINT [FK_MedicamentPrescriptions]
    FOREIGN KEY ([Prescription_id])
    REFERENCES [dbo].[Prescriptions]
        ([Prescription_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MedicamentPrescriptions'
CREATE INDEX [IX_FK_MedicamentPrescriptions]
ON [dbo].[Medicaments]
    ([Prescription_id]);
GO

-- Creating foreign key on [Patient_Id] in table 'MedicationReactions'
ALTER TABLE [dbo].[MedicationReactions]
ADD CONSTRAINT [FK_med_Patientmed_MedicationReaction]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_MedicationReaction'
CREATE INDEX [IX_FK_med_Patientmed_MedicationReaction]
ON [dbo].[MedicationReactions]
    ([Patient_Id]);
GO

-- Creating foreign key on [Perinatal_id] in table 'Newborns'
ALTER TABLE [dbo].[Newborns]
ADD CONSTRAINT [FK_med_perinatalmed_newborn]
    FOREIGN KEY ([Perinatal_id])
    REFERENCES [dbo].[Perinatals]
        ([Perinatal_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_perinatalmed_newborn'
CREATE INDEX [IX_FK_med_perinatalmed_newborn]
ON [dbo].[Newborns]
    ([Perinatal_id]);
GO

-- Creating foreign key on [Pat_category_Id] in table 'Pathologies'
ALTER TABLE [dbo].[Pathologies]
ADD CONSTRAINT [FK_med_pathology_categorymed_pathology]
    FOREIGN KEY ([Pat_category_Id])
    REFERENCES [dbo].[Pathology_Categories]
        ([Pat_category_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_pathology_categorymed_pathology'
CREATE INDEX [IX_FK_med_pathology_categorymed_pathology]
ON [dbo].[Pathologies]
    ([Pat_category_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'PatientAllergies'
ALTER TABLE [dbo].[PatientAllergies]
ADD CONSTRAINT [FK_med_Patientmed_PatientAllergy]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_PatientAllergy'
CREATE INDEX [IX_FK_med_Patientmed_PatientAllergy]
ON [dbo].[PatientAllergies]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Perinatals'
ALTER TABLE [dbo].[Perinatals]
ADD CONSTRAINT [FK_med_Patientmed_perinatal]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_perinatal'
CREATE INDEX [IX_FK_med_Patientmed_perinatal]
ON [dbo].[Perinatals]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Prescriptions'
ALTER TABLE [dbo].[Prescriptions]
ADD CONSTRAINT [FK_med_Patientmed_Prescriptions]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Prescriptions'
CREATE INDEX [IX_FK_med_Patientmed_Prescriptions]
ON [dbo].[Prescriptions]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Surgeries'
ALTER TABLE [dbo].[Surgeries]
ADD CONSTRAINT [FK_med_Patientmed_Surgeries]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Surgeries'
CREATE INDEX [IX_FK_med_Patientmed_Surgeries]
ON [dbo].[Surgeries]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'SystemReviews'
ALTER TABLE [dbo].[SystemReviews]
ADD CONSTRAINT [FK_med_Patientmed_SystemReview]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_SystemReview'
CREATE INDEX [IX_FK_med_Patientmed_SystemReview]
ON [dbo].[SystemReviews]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'Vaccinations'
ALTER TABLE [dbo].[Vaccinations]
ADD CONSTRAINT [FK_med_Patientmed_Vacines]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_Vacines'
CREATE INDEX [IX_FK_med_Patientmed_Vacines]
ON [dbo].[Vaccinations]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'WorkFlows'
ALTER TABLE [dbo].[WorkFlows]
ADD CONSTRAINT [FK_med_Patientmed_WorkFlow]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_Patientmed_WorkFlow'
CREATE INDEX [IX_FK_med_Patientmed_WorkFlow]
ON [dbo].[WorkFlows]
    ([Patient_Id]);
GO

-- Creating foreign key on [Patient_Id] in table 'PediatricPSCs'
ALTER TABLE [dbo].[PediatricPSCs]
ADD CONSTRAINT [FK_PediatricPSCPatient]
    FOREIGN KEY ([Patient_Id])
    REFERENCES [dbo].[Patients]
        ([Patient_Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PediatricPSCPatient'
CREATE INDEX [IX_FK_PediatricPSCPatient]
ON [dbo].[PediatricPSCs]
    ([Patient_Id]);
GO

-- Creating foreign key on [Perinatal_id] in table 'Perinatal_monitors'
ALTER TABLE [dbo].[Perinatal_monitors]
ADD CONSTRAINT [FK_med_perinatalmed_perinatal_monitor]
    FOREIGN KEY ([Perinatal_id])
    REFERENCES [dbo].[Perinatals]
        ([Perinatal_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_perinatalmed_perinatal_monitor'
CREATE INDEX [IX_FK_med_perinatalmed_perinatal_monitor]
ON [dbo].[Perinatal_monitors]
    ([Perinatal_id]);
GO

-- Creating foreign key on [Perinatal_id] in table 'Puerperium_monitors'
ALTER TABLE [dbo].[Puerperium_monitors]
ADD CONSTRAINT [FK_med_perinatalmed_puerperium_monitor]
    FOREIGN KEY ([Perinatal_id])
    REFERENCES [dbo].[Perinatals]
        ([Perinatal_id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_med_perinatalmed_puerperium_monitor'
CREATE INDEX [IX_FK_med_perinatalmed_puerperium_monitor]
ON [dbo].[Puerperium_monitors]
    ([Perinatal_id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------